diff options
-rw-r--r-- | Python/importdl.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/Python/importdl.c b/Python/importdl.c index 4a1048d..9255bbf 100644 --- a/Python/importdl.c +++ b/Python/importdl.c @@ -22,7 +22,7 @@ PyObject * _PyImport_LoadDynamicModule(char *name, char *pathname, FILE *fp) { PyObject *m, *d, *s; - char *lastdot, *shortname, *packagecontext; + char *lastdot, *shortname, *packagecontext, *oldcontext; dl_funcptr p; if ((m = _PyImport_FindExtension(name, pathname)) != NULL) { @@ -48,9 +48,10 @@ _PyImport_LoadDynamicModule(char *name, char *pathname, FILE *fp) shortname); return NULL; } + oldcontext = _Py_PackageContext; _Py_PackageContext = packagecontext; (*p)(); - _Py_PackageContext = NULL; + _Py_PackageContext = oldcontext; if (PyErr_Occurred()) return NULL; if (_PyImport_FixupExtension(name, pathname) == NULL) |