requests icon indicating copy to clipboard operation
requests copied to clipboard

fix: use context manager for ZipFile in extract_zipped_paths

Open shindonghwi opened this issue 11 months ago • 0 comments

Found that extract_zipped_paths() opens a ZipFile but never closes it.

When member is not found and returns early, the ZipFile remains open. Fixed by wrapping with context manager.

# before
zip_file = zipfile.ZipFile(archive)
if member not in zip_file.namelist():
    return path  # leak

# after  
with zipfile.ZipFile(archive) as zip_file:
    if member not in zip_file.namelist():
        return path  # properly closed

Added a test to verify close() is called.

shindonghwi avatar Dec 19 '25 02:12 shindonghwi