Commit 4ecf1602 authored by Marc-André Lemburg's avatar Marc-André Lemburg

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.
parent 076b3081
...@@ -1458,13 +1458,13 @@ PyImport_ImportFrozenModule(char *name) ...@@ -1458,13 +1458,13 @@ PyImport_ImportFrozenModule(char *name)
PyObject * PyObject *
PyImport_ImportModule(char *name) PyImport_ImportModule(char *name)
{ {
static PyObject *fromlist = NULL; PyObject *pname;
if (fromlist == NULL && strchr(name, '.') != NULL) { PyObject *result;
fromlist = Py_BuildValue("(s)", "*");
if (fromlist == NULL) pname = PyString_FromString(name);
return NULL; result = PyImport_Import(pname);
} Py_DECREF(pname);
return PyImport_ImportModuleEx(name, NULL, NULL, fromlist); return result;
} }
/* Forward declarations for helper routines */ /* Forward declarations for helper routines */
...@@ -1906,7 +1906,8 @@ PyImport_Import(PyObject *module_name) ...@@ -1906,7 +1906,8 @@ PyImport_Import(PyObject *module_name)
if (standard_builtins == NULL) { if (standard_builtins == NULL) {
standard_builtins = standard_builtins =
PyImport_ImportModule("__builtin__"); PyImport_ImportModuleEx("__builtin__",
NULL, NULL, NULL);
if (standard_builtins == NULL) if (standard_builtins == NULL)
return NULL; return NULL;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment