-
-
Notifications
You must be signed in to change notification settings - Fork 32.8k
Open
Labels
extension-modulesC modules in the Modules dirC modules in the Modules dirtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
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.
cpython/Lib/test/test_io/test_general.py
Lines 2281 to 2288 in 6bc65c3
def test_readinto(self): | |
for method in ("readinto", "readinto1"): | |
with self.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 -- Unraisable exception
Exception ignored while finalizing file <_io.BufferedRWPair object at 0x7fd9d7577950>:
Traceback (most recent call last):
File "<checkout_dir>/cpython/Lib/test/support/__init__.py", line 837, in gc_collect
gc.collect()
~~~~~~~~~~^^
ValueError: flush of closed file
Warning -- Unraisable exception
Exception ignored while finalizing file <_io.BufferedWriter>:
Traceback (most recent call last):
File "<checkout_dir>/cpython/Lib/test/support/__init__.py", line 837, in gc_collect
gc.collect()
~~~~~~~~~~^^
ValueError: flush of closed file
Found while working on GH-138475
CPython versions tested on:
CPython main branch
Operating systems tested on:
Linux
Linked PRs
Metadata
Metadata
Assignees
Labels
extension-modulesC modules in the Modules dirC modules in the Modules dirtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error