summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_io.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test/test_io.py')
-rw-r--r--Lib/test/test_io.py19
1 files changed, 18 insertions, 1 deletions
diff --git a/Lib/test/test_io.py b/Lib/test/test_io.py
index 0ffb4a1..419921f 100644
--- a/Lib/test/test_io.py
+++ b/Lib/test/test_io.py
@@ -611,7 +611,24 @@ class IOTest(unittest.TestCase):
self.assertEqual(rawio.read(2), b"")
class CIOTest(IOTest):
- pass
+
+ def test_IOBase_finalize(self):
+ # Issue #12149: segmentation fault on _PyIOBase_finalize when both a
+ # class which inherits IOBase and an object of this class are caught
+ # in a reference cycle and close() is already in the method cache.
+ class MyIO(self.IOBase):
+ def close(self):
+ pass
+
+ # create an instance to populate the method cache
+ MyIO()
+ obj = MyIO()
+ obj.obj = obj
+ wr = weakref.ref(obj)
+ del MyIO
+ del obj
+ support.gc_collect()
+ self.assertTrue(wr() is None, wr)
class PyIOTest(IOTest):
pass