Mercurial > cpython-lru_cache-weakref
diff Python/import.c @ 27357:afd1dc62e354 legacy-trunk
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.
| author | Jack Jansen <jack.jansen@cwi.nl> |
|---|---|
| date | Fri, 24 Jan 2003 16:15:45 +0000 |
| parents | 54aacb87beda |
| children | 4b75a0b76857 |
line wrap: on
line diff
--- a/Python/import.c Fri Jan 24 15:31:31 2003 +0000 +++ b/Python/import.c Fri Jan 24 16:15:45 2003 +0000 @@ -1214,23 +1214,26 @@ ** Speedup: each sys.path item is interned, and ** FindResourceModule remembers which items refer to ** folders (so we don't have to bother trying to look - ** into them for resources). + ** into them for resources). We only do this for string + ** items. */ - PyString_InternInPlace(&PyList_GET_ITEM(path, i)); - v = PyList_GET_ITEM(path, i); - if (PyMac_FindResourceModule((PyStringObject *)v, name, buf)) { - static struct filedescr resfiledescr = - {"", "", PY_RESOURCE}; + if (PyString_Check(PyList_GET_ITEM(path, i))) { + PyString_InternInPlace(&PyList_GET_ITEM(path, i)); + v = PyList_GET_ITEM(path, i); + if (PyMac_FindResourceModule((PyStringObject *)v, name, buf)) { + static struct filedescr resfiledescr = + {"", "", PY_RESOURCE}; - Py_XDECREF(copy); - return &resfiledescr; - } - if (PyMac_FindCodeResourceModule((PyStringObject *)v, name, buf)) { - static struct filedescr resfiledescr = - {"", "", PY_CODERESOURCE}; + Py_XDECREF(copy); + return &resfiledescr; + } + if (PyMac_FindCodeResourceModule((PyStringObject *)v, name, buf)) { + static struct filedescr resfiledescr = + {"", "", PY_CODERESOURCE}; - Py_XDECREF(copy); - return &resfiledescr; + Py_XDECREF(copy); + return &resfiledescr; + } } #endif if (len > 0 && buf[len-1] != SEP
