From e81e9b1d3be5c2197235e3dc130c41f18a42edf7 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Martin=20v=2E=20L=C3=B6wis?= Date: Thu, 4 Sep 2003 18:45:59 +0000 Subject: [PATCH] Patch #794826: Add __file__ in dynamically loaded modules for multiple interpreters. Fixes #698282. Will backport to 2.3. --- Python/importdl.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Python/importdl.c b/Python/importdl.c index c2400f7a3c..9c325e447d 100644 --- a/Python/importdl.c +++ b/Python/importdl.c @@ -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", -- 2.50.1