]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Patch #794826: Add __file__ in dynamically loaded modules for multiple
authorMartin v. Löwis <martin@v.loewis.de>
Thu, 4 Sep 2003 18:46:39 +0000 (18:46 +0000)
committerMartin v. Löwis <martin@v.loewis.de>
Thu, 4 Sep 2003 18:46:39 +0000 (18:46 +0000)
interpreters. Fixes #698282.

Misc/NEWS
Python/importdl.c

index 214eb3542225076c58427bf12fa4632179602175..59959debc1144c1f3b8a757a00459a35bbcd7f37 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -20,6 +20,8 @@ Core and builtins
 Extension modules
 -----------------
 
+- Bug #698282: Add __file__ to dynamic modules in multiple interpreters.
+
 - Patch #798145: Return correct information from nl_langinfo(RADIXCHAR).
 
 - Bug #797447: Correct confusing error message for unsupported locales.
index c2400f7a3ced3529ace558374983d7f51f96ec32..9c325e447d3f485144f4210e9714c5782cd354da 100644 (file)
@@ -54,8 +54,6 @@ _PyImport_LoadDynamicModule(char *name, char *pathname, FILE *fp)
        _Py_PackageContext = oldcontext;
        if (PyErr_Occurred())
                return NULL;
-       if (_PyImport_FixupExtension(name, pathname) == NULL)
-               return NULL;
 
        m = PyDict_GetItemString(PyImport_GetModuleDict(), name);
        if (m == NULL) {
@@ -66,6 +64,9 @@ _PyImport_LoadDynamicModule(char *name, char *pathname, FILE *fp)
        /* Remember the filename as the __file__ attribute */
        if (PyModule_AddStringConstant(m, "__file__", pathname) < 0)
                PyErr_Clear(); /* Not important enough to report */
+
+       if (_PyImport_FixupExtension(name, pathname) == NULL)
+               return NULL;
        if (Py_VerboseFlag)
                PySys_WriteStderr(
                        "import %s # dynamically loaded from %s\n",