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

Skip to content

Commit 9e473c2

Browse files
committed
SF patch# 1758570 by Jeffrey Yasskin, who writes:
I made Carbon.File.pathname return unicode, by analogy with macpath.abspath. There could easily be other bugs of the same sort in this file. The uses of PyString_FromString*() in particular look sketchy.
1 parent f520c05 commit 9e473c2

1 file changed

Lines changed: 3 additions & 7 deletions

File tree

Mac/Modules/file/_Filemodule.c

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3033,12 +3033,8 @@ static PyObject *File_pathname(PyObject *_self, PyObject *_args)
30333033

30343034
if (!PyArg_ParseTuple(_args, "O", &obj))
30353035
return NULL;
3036-
if (PyString_Check(obj)) {
3037-
Py_INCREF(obj);
3038-
return obj;
3039-
}
3040-
if (PyUnicode_Check(obj))
3041-
return PyUnicode_AsEncodedString(obj, "utf8", "strict");
3036+
if (PyString_Check(obj) || PyUnicode_Check(obj))
3037+
return PyUnicode_FromObject(obj);
30423038
_res = PyObject_CallMethod(obj, "as_pathname", NULL);
30433039
return _res;
30443040

@@ -3140,7 +3136,7 @@ static PyMethodDef File_methods[] = {
31403136
{"FSUpdateAlias", (PyCFunction)File_FSUpdateAlias, 1,
31413137
PyDoc_STR("(FSRef fromFile, FSRef target, AliasHandle alias) -> (Boolean wasChanged)")},
31423138
{"pathname", (PyCFunction)File_pathname, 1,
3143-
PyDoc_STR("(str|unicode|FSSpec|FSref) -> pathname")},
3139+
PyDoc_STR("(str|FSSpec|FSref) -> pathname")},
31443140
{NULL, NULL, 0}
31453141
};
31463142

0 commit comments

Comments
 (0)