Repository navigation
ResourceWarning: unclosed file on buildbots from test_frame #96696
Copy link
Copy link
Closed
Labels
3.11only security fixesonly security fixes3.12only security fixesonly security fixestestsTests in the Lib/test dirTests in the Lib/test dirtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
Example warning output from https://buildbot.python.org/all/#/builders/558/builds/802 :
/home/dje/cpython-buildarea/pull_request.edelsohn-fedora-z.refleak/build/Lib/test/test_frame.py:258: ResourceWarning: unclosed file <_io.TextIOWrapper name='/home/dje/cpython-buildarea/pull_request.edelsohn-fedora-z.refleak/build/Lib/test/test_frame.py' mode='r' encoding='UTF-8'>
ResourceWarning: Enable tracemalloc to get the object allocation traceback
./home/dje/cpython-buildarea/pull_request.edelsohn-fedora-z.refleak/build/Lib/test/test_frame.py:258: ResourceWarning: unclosed file <_io.TextIOWrapper name='/home/dje/cpython-buildarea/pull_request.edelsohn-fedora-z.refleak/build/Lib/test/test_frame.py' mode='r' encoding='UTF-8'>
ResourceWarning: Enable tracemalloc to get the object allocation traceback
./home/dje/cpython-buildarea/pull_request.edelsohn-fedora-z.refleak/build/Lib/test/test_frame.py:258: ResourceWarning: unclosed file <_io.TextIOWrapper name='/home/dje/cpython-buildarea/pull_request.edelsohn-fedora-z.refleak/build/Lib/test/test_frame.py' mode='r' encoding='UTF-8'>
ResourceWarning: Enable tracemalloc to get the object allocation traceback
./home/dje/cpython-buildarea/pull_request.edelsohn-fedora-z.refleak/build/Lib/test/test_frame.py:258: ResourceWarning: unclosed file <_io.TextIOWrapper name='/home/dje/cpython-buildarea/pull_request.edelsohn-fedora-z.refleak/build/Lib/test/test_frame.py' mode='r' encoding='UTF-8'>
ResourceWarning: Enable tracemalloc to get the object allocation traceback
./home/dje/cpython-buildarea/pull_request.edelsohn-fedora-z.refleak/build/Lib/test/test_frame.py:258: ResourceWarning: unclosed file <_io.TextIOWrapper name='/home/dje/cpython-buildarea/pull_request.edelsohn-fedora-z.refleak/build/Lib/test/test_frame.py' mode='r' encoding='UTF-8'>
ResourceWarning: Enable tracemalloc to get the object allocation traceback
./home/dje/cpython-buildarea/pull_request.edelsohn-fedora-z.refleak/build/Lib/test/test_frame.py:258: ResourceWarning: unclosed file <_io.TextIOWrapper name='/home/dje/cpython-buildarea/pull_request.edelsohn-fedora-z.refleak/build/Lib/test/test_frame.py' mode='r' encoding='UTF-8'>
ResourceWarning: Enable tracemalloc to get the object allocation traceback
I believe this is related to the following delicate test case:
cpython/Lib/test/test_frame.py
Lines 238 to 258 in 95d6330
| class TestIncompleteFrameAreInvisible(unittest.TestCase): | |
| def test_issue95818(self): | |
| #See GH-95818 for details | |
| import gc | |
| self.addCleanup(gc.set_threshold, *gc.get_threshold()) | |
| gc.set_threshold(1,1,1) | |
| class GCHello: | |
| def __del__(self): | |
| print("Destroyed from gc") | |
| def gen(): | |
| yield | |
| fd = open(__file__) | |
| l = [fd, GCHello()] | |
| l.append(l) | |
| del fd | |
| del l | |
| gen() |
Presumably, we could either find a reproducer that doesn't leak resources, or suppress the warnings and/or run the test isolated in a separate process.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
3.11only security fixesonly security fixes3.12only security fixesonly security fixestestsTests in the Lib/test dirTests in the Lib/test dirtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Activity