Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 60ffc2b

Browse files
committed
Added a missing INCREF in pathname().
1 parent 47a6b13 commit 60ffc2b

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

Mac/Modules/file/_Filemodule.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3026,8 +3026,10 @@ static PyObject *File_pathname(PyObject *_self, PyObject *_args)
30263026

30273027
if (!PyArg_ParseTuple(_args, "O", &obj))
30283028
return NULL;
3029-
if (PyString_Check(obj))
3029+
if (PyString_Check(obj)) {
3030+
Py_INCREF(obj);
30303031
return obj;
3032+
}
30313033
if (PyUnicode_Check(obj))
30323034
return PyUnicode_AsEncodedString(obj, "utf8", "strict");
30333035
_res = PyObject_CallMethod(obj, "as_pathname", NULL);

Mac/Modules/file/filesupport.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -874,8 +874,10 @@ def parseArgumentList(self, args):
874874
875875
if (!PyArg_ParseTuple(_args, "O", &obj))
876876
return NULL;
877-
if (PyString_Check(obj))
877+
if (PyString_Check(obj)) {
878+
Py_INCREF(obj);
878879
return obj;
880+
}
879881
if (PyUnicode_Check(obj))
880882
return PyUnicode_AsEncodedString(obj, "utf8", "strict");
881883
_res = PyObject_CallMethod(obj, "as_pathname", NULL);

0 commit comments

Comments
 (0)