@@ -998,24 +998,24 @@ PyDoc_STRVAR(Diff_parse_diff__doc__,
998998 "Parses a git unified diff into a diff object without a repository" );
999999
10001000static PyObject *
1001- Diff_parse_diff (PyObject * self , PyObject * args )
1001+ Diff_parse_diff (PyObject * self , PyObject * py_str )
10021002{
1003- /* A wrapper around
1004- * git_diff_from_buffer
1005- */
1006- git_diff * diff ;
1007- const char * content = NULL ;
1008- Py_ssize_t content_len ;
1009- int err ;
1010-
1011- if (!PyArg_ParseTuple (args , "s#" , & content , & content_len ))
1012- return NULL ;
1003+ /* A wrapper around git_diff_from_buffer */
1004+ git_diff * diff ;
1005+ const char * content = NULL ;
1006+ int err ;
1007+ PyObject * tvalue ;
10131008
1014- err = git_diff_from_buffer (& diff , content , content_len );
1015- if (err < 0 )
1016- return Error_set (err );
1009+ content = py_str_borrow_c_str (& tvalue , py_str , NULL );
1010+ if (content == NULL )
1011+ return NULL ;
1012+
1013+ err = git_diff_from_buffer (& diff , content , strlen (content ));
1014+ Py_DECREF (tvalue );
1015+ if (err < 0 )
1016+ return Error_set (err );
10171017
1018- return wrap_diff (diff , NULL );
1018+ return wrap_diff (diff , NULL );
10191019}
10201020
10211021static void
@@ -1044,7 +1044,7 @@ static PyMethodDef Diff_methods[] = {
10441044 METHOD (Diff , find_similar , METH_VARARGS | METH_KEYWORDS ),
10451045 METHOD (Diff , from_c , METH_STATIC | METH_VARARGS ),
10461046 {"parse_diff" , (PyCFunction ) Diff_parse_diff ,
1047- METH_VARARGS | METH_STATIC , Diff_parse_diff__doc__ },
1047+ METH_O | METH_STATIC , Diff_parse_diff__doc__ },
10481048 {NULL }
10491049};
10501050
0 commit comments