Mercurial > cpython-lru_cache-weakref
diff Python/import.c @ 76390:db5e3431ee4c
rollback 005fd1fe31ab (see #14609 and #14582)
Being able to overload a sys.module entry during import of a module was broken
by this changeset.
| author | Benjamin Peterson <benjamin@python.org> |
|---|---|
| date | Wed, 18 Apr 2012 10:55:43 -0400 |
| parents | 66bd85bcf916 |
| children | b773a751c2e7 |
line wrap: on
line diff
--- a/Python/import.c Wed Apr 18 10:48:00 2012 -0400 +++ b/Python/import.c Wed Apr 18 10:55:43 2012 -0400 @@ -2447,22 +2447,15 @@ Py_DECREF(partition); if (level == 0) { - if (PyUnicode_GET_LENGTH(name) == - PyUnicode_GET_LENGTH(front)) { - final_mod = mod; + final_mod = PyDict_GetItem(interp->modules, front); + Py_DECREF(front); + if (final_mod == NULL) { + PyErr_Format(PyExc_KeyError, + "%R not in sys.modules as expected", front); } else { - final_mod = PyDict_GetItem(interp->modules, front); - if (final_mod == NULL) { - PyErr_Format(PyExc_KeyError, - "%R not in sys.modules as expected", front); - } + Py_INCREF(final_mod); } - Py_DECREF(front); - if (final_mod == NULL) { - goto error_with_unlock; - } - Py_INCREF(final_mod); } else { Py_ssize_t cut_off = PyUnicode_GET_LENGTH(name) -
