Kaydet (Commit) e81e9b1d authored tarafından Martin v. Löwis's avatar Martin v. Löwis

Patch #794826: Add __file__ in dynamically loaded modules for multiple

interpreters. Fixes #698282. Will backport to 2.3.
üst ef36537b
...@@ -54,8 +54,6 @@ _PyImport_LoadDynamicModule(char *name, char *pathname, FILE *fp) ...@@ -54,8 +54,6 @@ _PyImport_LoadDynamicModule(char *name, char *pathname, FILE *fp)
_Py_PackageContext = oldcontext; _Py_PackageContext = oldcontext;
if (PyErr_Occurred()) if (PyErr_Occurred())
return NULL; return NULL;
if (_PyImport_FixupExtension(name, pathname) == NULL)
return NULL;
m = PyDict_GetItemString(PyImport_GetModuleDict(), name); m = PyDict_GetItemString(PyImport_GetModuleDict(), name);
if (m == NULL) { if (m == NULL) {
...@@ -66,6 +64,9 @@ _PyImport_LoadDynamicModule(char *name, char *pathname, FILE *fp) ...@@ -66,6 +64,9 @@ _PyImport_LoadDynamicModule(char *name, char *pathname, FILE *fp)
/* Remember the filename as the __file__ attribute */ /* Remember the filename as the __file__ attribute */
if (PyModule_AddStringConstant(m, "__file__", pathname) < 0) if (PyModule_AddStringConstant(m, "__file__", pathname) < 0)
PyErr_Clear(); /* Not important enough to report */ PyErr_Clear(); /* Not important enough to report */
if (_PyImport_FixupExtension(name, pathname) == NULL)
return NULL;
if (Py_VerboseFlag) if (Py_VerboseFlag)
PySys_WriteStderr( PySys_WriteStderr(
"import %s # dynamically loaded from %s\n", "import %s # dynamically loaded from %s\n",
......
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