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

Skip to content

Commit 9363dca

Browse files
committed
MacPython-OS9 specific fix: If there are non-string items on sys.path don't try to intern them. This has the theoretical problem that resource filenames on sys.path cannot be unicode objects, but in practice that shouldn't matter.
1 parent 0064026 commit 9363dca

1 file changed

Lines changed: 18 additions & 15 deletions

File tree

Python/import.c

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1214,23 +1214,26 @@ find_module(char *fullname, char *subname, PyObject *path, char *buf,
12141214
** Speedup: each sys.path item is interned, and
12151215
** FindResourceModule remembers which items refer to
12161216
** folders (so we don't have to bother trying to look
1217-
** into them for resources).
1217+
** into them for resources). We only do this for string
1218+
** items.
12181219
*/
1219-
PyString_InternInPlace(&PyList_GET_ITEM(path, i));
1220-
v = PyList_GET_ITEM(path, i);
1221-
if (PyMac_FindResourceModule((PyStringObject *)v, name, buf)) {
1222-
static struct filedescr resfiledescr =
1223-
{"", "", PY_RESOURCE};
1224-
1225-
Py_XDECREF(copy);
1226-
return &resfiledescr;
1227-
}
1228-
if (PyMac_FindCodeResourceModule((PyStringObject *)v, name, buf)) {
1229-
static struct filedescr resfiledescr =
1230-
{"", "", PY_CODERESOURCE};
1220+
if (PyString_Check(PyList_GET_ITEM(path, i))) {
1221+
PyString_InternInPlace(&PyList_GET_ITEM(path, i));
1222+
v = PyList_GET_ITEM(path, i);
1223+
if (PyMac_FindResourceModule((PyStringObject *)v, name, buf)) {
1224+
static struct filedescr resfiledescr =
1225+
{"", "", PY_RESOURCE};
1226+
1227+
Py_XDECREF(copy);
1228+
return &resfiledescr;
1229+
}
1230+
if (PyMac_FindCodeResourceModule((PyStringObject *)v, name, buf)) {
1231+
static struct filedescr resfiledescr =
1232+
{"", "", PY_CODERESOURCE};
12311233

1232-
Py_XDECREF(copy);
1233-
return &resfiledescr;
1234+
Py_XDECREF(copy);
1235+
return &resfiledescr;
1236+
}
12341237
}
12351238
#endif
12361239
if (len > 0 && buf[len-1] != SEP

0 commit comments

Comments
 (0)