Skip to content

Close zip files on sys.path when the path cache is cleared. - #563

Open
cmaloney wants to merge 3 commits into
python:mainfrom
cmaloney:bugfix/cpython-162342-zip-cycles
Open

cmaloney wants to merge 3 commits into
python:mainfrom
cmaloney:bugfix/cpython-162342-zip-cycles

Conversation

@cmaloney

Copy link
Copy Markdown

Reference cycles kept each zip's open ZipFile alive until the cyclic garbage collector ran, which could emit a ResourceWarning depending on finalization order.

  • Stop storing self in freeze() and instead just branch in __missing__ based on the value of self._frozen
  • Change bound_method to only keep a weak reference to self

Closes #562.

cmaloney and others added 2 commits November 20, 2026 21:39
Reference cycles kept each zip's open `ZipFile` alive until the cyclic
garbage collector ran, which could emit a `ResourceWarning` depending on
finalization order.

Closes python#562.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
PyPy only closes the zip at garbage collection.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Comment thread tests/test_zip.py Resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant