Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Copy the filename into main interpreter before intern in import.c
  • Loading branch information
aisk committed Jun 10, 2024
commit 65410868bca9efbcdd3a889cde6ff64098a8c3d4
7 changes: 6 additions & 1 deletion Python/import.c
Original file line number Diff line number Diff line change
Expand Up @@ -1969,7 +1969,12 @@ import_run_extension(PyThreadState *tstate, PyModInitFunction p0,
if (info->filename != NULL) {
// XXX There's a refleak somewhere with the filename.
// Until we can track it down, we intern it.
PyObject *filename = Py_NewRef(info->filename);
// The original filename may be allocated by subinterpreter's
// obmaloc, so we create a copy here.
PyObject *filename = PyUnicode_FromString(PyUnicode_AsUTF8(info->filename));
if (filename == NULL) {
return NULL;
}
PyUnicode_InternInPlace(&filename);
if (PyModule_AddObjectRef(mod, "__file__", filename) < 0) {
PyErr_Clear(); /* Not important enough to report */
Expand Down