diff options
author | Marc-André Lemburg <mal@egenix.com> | 2001-02-09 19:40:15 (GMT) |
---|---|---|
committer | Marc-André Lemburg <mal@egenix.com> | 2001-02-09 19:40:15 (GMT) |
commit | 3c61c3525f4cf23acae95c5229abd10fe0998d28 (patch) | |
tree | 216162b106115635a7c16353a2de5de76b0e67c4 /Python | |
parent | dbbbaf26969547b3cdd1b0eabc922e7d3f37cf99 (diff) | |
download | cpython-3c61c3525f4cf23acae95c5229abd10fe0998d28.zip cpython-3c61c3525f4cf23acae95c5229abd10fe0998d28.tar.gz cpython-3c61c3525f4cf23acae95c5229abd10fe0998d28.tar.bz2 |
This modified version of a patch by Thomas Heller allows __import__
hooks to take over the Python import machinery at a very early stage
in the Python startup phase.
If there are still places in the Python interpreter which need to
bypass the __import__ hook, these places must now use
PyImport_ImportModuleEx() instead. So far no other places than in
the import mechanism itself have been identified.
Diffstat (limited to 'Python')
-rw-r--r-- | Python/import.c | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/Python/import.c b/Python/import.c index 391658e..71af3bd 100644 --- a/Python/import.c +++ b/Python/import.c @@ -1458,13 +1458,13 @@ PyImport_ImportFrozenModule(char *name) PyObject * PyImport_ImportModule(char *name) { - static PyObject *fromlist = NULL; - if (fromlist == NULL && strchr(name, '.') != NULL) { - fromlist = Py_BuildValue("(s)", "*"); - if (fromlist == NULL) - return NULL; - } - return PyImport_ImportModuleEx(name, NULL, NULL, fromlist); + PyObject *pname; + PyObject *result; + + pname = PyString_FromString(name); + result = PyImport_Import(pname); + Py_DECREF(pname); + return result; } /* Forward declarations for helper routines */ @@ -1906,7 +1906,8 @@ PyImport_Import(PyObject *module_name) if (standard_builtins == NULL) { standard_builtins = - PyImport_ImportModule("__builtin__"); + PyImport_ImportModuleEx("__builtin__", + NULL, NULL, NULL); if (standard_builtins == NULL) return NULL; } |