-
-
Notifications
You must be signed in to change notification settings - Fork 33.2k
gh-129726: Break gzip.GzipFile reference loop
#130055
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,6 +10,7 @@ | |
| import builtins | ||
| import io | ||
| import _compression | ||
| import weakref | ||
|
|
||
| __all__ = ["BadGzipFile", "GzipFile", "open", "compress", "decompress"] | ||
|
|
||
|
|
@@ -226,7 +227,8 @@ def __init__(self, filename=None, mode=None, | |
| 0) | ||
| self._write_mtime = mtime | ||
| self._buffer_size = _WRITE_BUFFER_SIZE | ||
| self._buffer = io.BufferedWriter(_WriteBufferStream(self), | ||
| write_wrap = _WriteBufferStream(weakref.proxy(self)) | ||
|
||
| self._buffer = io.BufferedWriter(write_wrap, | ||
| buffer_size=self._buffer_size) | ||
| else: | ||
| raise ValueError("Invalid mode: {!r}".format(mode)) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| Fix :class:`gzip.GzipFile` raising an unraisable exception during garbage | ||
| collection when referring to a temporary object by breaking the reference | ||
| loop with :mod:`weakref`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the ordering of imports here is painful to me, but resisted bringing to PEP8 because this fix needs backporting.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please reformat these imports for PEP 8 :-) I will handle merge conflicts on backports if needed.