summaryrefslogtreecommitdiffstats
path: root/Python/importdl.c
diff options
context:
space:
mode:
authorEric Snow <ericsnowcurrently@gmail.com>2024-04-24 15:55:48 (GMT)
committerGitHub <noreply@github.com>2024-04-24 15:55:48 (GMT)
commitaf3c1d817d3f8369f8003965d967332a3a721a25 (patch)
treed78fb452aa5da4e1f61d1eaf8f48a470efd731e0 /Python/importdl.c
parent8227883d1f1bbb6560e5f175d7ee49f013c094bd (diff)
downloadcpython-af3c1d817d3f8369f8003965d967332a3a721a25.zip
cpython-af3c1d817d3f8369f8003965d967332a3a721a25.tar.gz
cpython-af3c1d817d3f8369f8003965d967332a3a721a25.tar.bz2
gh-117953: Cleanups For fix_up_extension() in import.c (gh-118192)
These are cleanups I've pulled out of gh-118116. Mostly, this change moves code around to align with some future changes and to improve clarity a little. There is one very small change in behavior: we now add the module to the per-interpreter caches after updating the global state, rather than before.
Diffstat (limited to 'Python/importdl.c')
-rw-r--r--Python/importdl.c5
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;