Skip to content

ResourceWarning: unclosed file on buildbots from test_frame #96696

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
sweeneyde opened this issue Sep 8, 2022 · 0 comments
Closed

ResourceWarning: unclosed file on buildbots from test_frame #96696

sweeneyde opened this issue Sep 8, 2022 · 0 comments
Assignees
Labels
3.11 only security fixes 3.12 only security fixes tests Tests in the Lib/test dir type-bug An unexpected behavior, bug, or error

Comments

@sweeneyde
Copy link
Member

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:

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.11 only security fixes 3.12 only security fixes tests Tests in the Lib/test dir type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

2 participants