diff options
Diffstat (limited to 'Python/importdl.c')
| -rw-r--r-- | Python/importdl.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/Python/importdl.c b/Python/importdl.c index 7cf30be..e512161 100644 --- a/Python/importdl.c +++ b/Python/importdl.c @@ -226,6 +226,11 @@ _PyImport_LoadDynamicModuleWithSpec(PyObject *spec, FILE *fp) } def->m_base.m_init = p0; + /* Remember the filename as the __file__ attribute */ + if (PyModule_AddObjectRef(m, "__file__", filename) < 0) { + PyErr_Clear(); /* Not important enough to report */ + } + PyObject *modules = PyImport_GetModuleDict(); if (_PyImport_FixupExtensionObject(m, name_unicode, filename, modules) < 0) goto error; |
