summaryrefslogtreecommitdiffstats
path: root/Python/import.c
diff options
context:
space:
mode:
Diffstat (limited to 'Python/import.c')
-rw-r--r--Python/import.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/Python/import.c b/Python/import.c
index 005f769..dc7ff90 100644
--- a/Python/import.c
+++ b/Python/import.c
@@ -1967,8 +1967,6 @@ import_run_extension(PyThreadState *tstate, PyModInitFunction p0,
if (res.kind == _Py_ext_module_kind_SINGLEPHASE) {
/* Remember the filename as the __file__ attribute */
if (info->filename != NULL) {
- // XXX There's a refleak somewhere with the filename.
- // Until we can track it down, we intern it.
PyObject *filename = NULL;
if (switched) {
// The original filename may be allocated by subinterpreter's
@@ -1980,7 +1978,11 @@ import_run_extension(PyThreadState *tstate, PyModInitFunction p0,
} else {
filename = Py_NewRef(info->filename);
}
- PyUnicode_InternInPlace(&filename);
+ // XXX There's a refleak somewhere with the filename.
+ // Until we can track it down, we immortalize it.
+ PyInterpreterState *interp = _PyInterpreterState_GET();
+ _PyUnicode_InternImmortal(interp, &filename);
+
if (PyModule_AddObjectRef(mod, "__file__", filename) < 0) {
PyErr_Clear(); /* Not important enough to report */
}