self.check_incompatible_here(module)
with self.subTest(f'{module}: strict, fresh'):
self.check_incompatible_fresh(module)
+ with self.subTest(f'{module}: isolated, fresh'):
+ self.check_incompatible_fresh(module, isolated=True)
@unittest.skipIf(_testmultiphase is None, "test requires _testmultiphase module")
def test_multi_init_extension_compat(self):
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);
+ PyObject *filename = NULL;
+ if (switched) {
+ // The original filename may be allocated by subinterpreter's
+ // obmalloc, so we create a copy here.
+ filename = _PyUnicode_Copy(info->filename);
+ if (filename == NULL) {
+ return NULL;
+ }
+ } else {
+ filename = Py_NewRef(info->filename);
+ }
PyUnicode_InternInPlace(&filename);
if (PyModule_AddObjectRef(mod, "__file__", filename) < 0) {
PyErr_Clear(); /* Not important enough to report */