Skip to content

Commit 6b61587

Browse files
committed
Simplify the test case.
Apparently, StringIO() objects are serialized.
1 parent e81b81f commit 6b61587

2 files changed

Lines changed: 11 additions & 10 deletions

File tree

Lib/test/test_interpreters/test_api.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2416,14 +2416,10 @@ def test_object_collected_after_proxy_closes(self):
24162416
buffer = io.StringIO()
24172417
interp = interpreters.create()
24182418
try:
2419-
def write_to_proxy(obj):
2420-
obj.file.write("hello")
2419+
with self.share(self.unshareable(buffer)):
2420+
pass
24212421

2422-
with self.share(self.unshareable(buffer)) as proxy:
2423-
self.assertIsNone(interp.call(write_to_proxy, proxy))
2424-
self.assertEqual(str(proxy.file), buffer)
2425-
2426-
self.assertEqual(buffer.getvalue(), "hellodone")
2422+
self.assertEqual(buffer.getvalue(), "done")
24272423
finally:
24282424
interp.close()
24292425

Modules/_interpretersmodule.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -805,10 +805,15 @@ _sharedobjectproxy_as_shared(_PyXI_proxy_share *share)
805805
static void
806806
_sharedobjectproxy_finish_share(_PyXI_proxy_share *share)
807807
{
808-
_PyXIData_Free(share->xidata);
808+
if (share->xidata != NULL) {
809+
_PyXIData_Free(share->xidata);
810+
}
809811
#ifdef Py_DEBUG
810812
share->xidata = NULL;
811-
share->object = NULL;
813+
if (share->object != NULL) {
814+
assert(PyUnstable_IsImmortal(share->object));
815+
share->object = NULL;
816+
}
812817
#endif
813818
}
814819

@@ -836,7 +841,7 @@ _sharedobjectproxy_wrap_result(SharedObjectProxy *self, PyObject *result,
836841
}
837842

838843
PyObject *ret = _sharedobjectproxy_as_shared(&shared_result);
839-
_sharedobjectproxy_finish_share(&shared_result);
844+
//_sharedobjectproxy_finish_share(&shared_result);
840845
return ret;
841846
}
842847

0 commit comments

Comments
 (0)