Bug report
Bug description:
In BufferedRWPairTest.test_readinto a BufferedRWPair is created but not explicitly closed which results in it being Garbage Collected (GC). During GC the destruction order often results in an unraisable exception. This can be reliably reproduced by modifying the test to end with support.gc_collect(). The BufferedRWPair should cleanup reliably in this case.
| deftest_readinto(self): |
| formethodin ("readinto", "readinto1"): |
| withself.subTest(method): |
| pair=self.tp(self.BytesIO(b"abcdef"), self.MockRawIO()) |
| |
| data=byteslike(b'\0'*5) |
| self.assertEqual(getattr(pair, method)(data), 5) |
| self.assertEqual(bytes(data), b"abcde") |
Warning--UnraisableexceptionExceptionignoredwhilefinalizingfile<_io.BufferedRWPairobjectat0x7fd9d7577950>:
Traceback (mostrecentcalllast):
File"<checkout_dir>/cpython/Lib/test/support/__init__.py", line837, ingc_collectgc.collect()
~~~~~~~~~~^^ValueError: flushofclosedfileWarning--UnraisableexceptionExceptionignoredwhilefinalizingfile<_io.BufferedWriter>:
Traceback (mostrecentcalllast):
File"<checkout_dir>/cpython/Lib/test/support/__init__.py", line837, ingc_collectgc.collect()
~~~~~~~~~~^^ValueError: flushofclosedfile
Found while working on GH-138475
CPython versions tested on:
CPython main branch
Operating systems tested on:
Linux
Linked PRs
Bug report
Bug description:
In
BufferedRWPairTest.test_readintoaBufferedRWPairis created but not explicitly closed which results in it being Garbage Collected (GC). During GC the destruction order often results in an unraisable exception. This can be reliably reproduced by modifying the test to end withsupport.gc_collect(). The BufferedRWPair should cleanup reliably in this case.cpython/Lib/test/test_io/test_general.py
Lines 2281 to 2288 in 6bc65c3
Found while working on GH-138475
CPython versions tested on:
CPython main branch
Operating systems tested on:
Linux
Linked PRs