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 files keep their buffer alive #59693
Comments
>>> f = open("LICENSE", "rb")
>>> sys.getsizeof(f)
4296
>>> f.close()
>>> sys.getsizeof(f)
4296 Instead of waiting for the file object's deallocation, perhaps we should free the buffer when it is closed? |
Sounds reasonable to me. |
I take care of this. |
Please, review patch |
The test should go in the 'SizeofTest' class and maybe a better test would be a variant of the test already in that class: @support.cpython_only
def test_buffer_freeing(self) :
bufsize = 4096
rawio = self.MockRawIO()
bufio = self.tp(rawio, buffer_size=bufsize)
size = sys.getsizeof(bufio) - bufsize
bufio.close()
self.assertEqual(sys.getsizeof(bufio), size) Otherwise, LGTM. |
Agree with Meador. |
This has to wait for 3.4, since it's an enhancement, not a bug. |
New changeset 4141c36954cd by Jesus Cea in branch 'default': |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: