summaryrefslogtreecommitdiffstats
path: root/Lib/zipfile
Commit message (Collapse)AuthorAgeFilesLines
* [3.13] gh-135276: Refresh `zipfile.Path` from zipp 3.23 (GH-135277) (#135279)Miss Islington (bot)2025-06-082-8/+8
| | | | | | | | | | | | | | * gh-135276: Refresh `zipfile.Path` from zipp 3.23 (GH-135277) Apply changes from zipp 3.23 (cherry picked from commit 8d6eb0c26276c4013346622580072908d46d2341) Co-authored-by: Jason R. Coombs <jaraco@jaraco.com> * Removed features slated for Python 3.15 only. --------- Co-authored-by: Jason R. Coombs <jaraco@jaraco.com>
* [3.13] gh-117779: Fix reading duplicated entries in zipfile by name ↵Miss Islington (bot)2025-04-081-4/+12
| | | | | | | (GH-129254) (GH-132263) (cherry picked from commit 0f04f2456a2ff996cc670342a287928ab5f9b706) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
* [3.13] GH-128131: Completely support random read access of uncompressed ↵Miss Islington (bot)2025-01-201-1/+3
| | | | | | | | | | unencrypted files in ZipFile (GH-128143) (#129091) GH-128131: Completely support random read access of uncompressed unencrypted files in ZipFile (GH-128143) (cherry picked from commit dda02eb7be62bf0af850a7521c77c90ea997df6c) Co-authored-by: 5ec1cff <56485584+5ec1cff@users.noreply.github.com> Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com> Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
* [3.13] gh-127847: Fix position in the special-cased zipfile seek (GH-127856) ↵Miss Islington (bot)2024-12-241-1/+4
| | | | | | | | | | | | | (#128225) gh-127847: Fix position in the special-cased zipfile seek (GH-127856) --------- (cherry picked from commit 7ed6c5c6961d0849f163d4d449fb36bae312b6bc) Co-authored-by: Dima Ryazanov <dima@bucket.xxx> Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com> Co-authored-by: Peter Bierma <zintensitydev@gmail.com> Co-authored-by: Jason R. Coombs <jaraco@jaraco.com>
* [3.13] gh-126565: Skip `zipfile.Path.exists` check in write mode (GH-126576) ↵Miss Islington (bot)2024-11-101-1/+1
| | | | | | | | | | | | | | | | | | (#126642) gh-126565: Skip `zipfile.Path.exists` check in write mode (GH-126576) When `zipfile.Path.open` is called, the implementation will check whether the path already exists in the ZIP file. However, this check is only required when the ZIP file is in read mode. By swapping arguments of the `and` operator, the short-circuiting will prevent the check from being run in write mode. This change will improve the performance of `open()`, because checking whether a file exists is slow in write mode, especially when the archive has many members. (cherry picked from commit 160758a574d12bf0d965d8206136e7da4f4fd6c3) Co-authored-by: Jan Hicken <janhicken@users.noreply.github.com>
* [3.13] gh-113977, gh-120754: Remove unbounded reads from zipfile (GH-122101) ↵Miss Islington (bot)2024-11-031-3/+3
| | | | | | | | | | | | | | | | | (#126348) gh-113977, gh-120754: Remove unbounded reads from zipfile (GH-122101) GH-113977, GH-120754: Remove unbounded reads from zipfile Read without a size may read an unbounded amount of data + allocate unbounded size buffers. Move to capped size reads to prevent potential issues. (cherry picked from commit 556dc9b8a78bad296513221f3f414a3f8fd0ae70) Co-authored-by: Cody Maloney <cmaloney@users.noreply.github.com> Co-authored-by: Daniel Hillier <daniel.hillier@gmail.com> Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
* [3.13] gh-123270: Replaced SanitizedNames with a more surgical fix. ↵Miss Islington (bot)2024-09-021-65/+17
| | | | | | | | | | (GH-123354) (#123410) gh-123270: Replaced SanitizedNames with a more surgical fix. (GH-123354) Applies changes from zipp 3.20.1 and jaraco/zippGH-124 (cherry picked from commit 2231286d78d328c2f575e0b05b16fe447d1656d6) Co-authored-by: Jason R. Coombs <jaraco@jaraco.com>
* [3.13] gh-122903: Honor directories in zipfile.Path.glob. (GH-122908) (#122926)Miss Islington (bot)2024-08-122-4/+14
| | | | (cherry picked from commit 6aa35f3002dda25858d47e702e750e2871e42a7c)
* [3.13] gh-122905: Sanitize names in zipfile.Path. (GH-122906) (#122922)Miss Islington (bot)2024-08-121-1/+63
|
* [3.13] gh-119588: Implement zipfile.Path.is_symlink (zipp 3.19.0). ↵Miss Islington (bot)2024-06-041-2/+5
| | | | | | | | (GH-119591) (#119985) gh-119588: Implement zipfile.Path.is_symlink (zipp 3.19.0). (GH-119591) (cherry picked from commit 42a34ddb0b63e638905b01e17a7254623a0de427) Co-authored-by: Jason R. Coombs <jaraco@jaraco.com>
* Fix typo in Lib/zipfile/_path/__init__.py (#118622)Xie Yanbo2024-05-061-1/+1
|
* gh-115961: Add name and mode attributes for compressed file-like objects ↵Serhiy Storchaka2024-04-211-2/+10
| | | | | | | | | | (GH-116036) * Add name and mode attributes for compressed and archived file-like objects in modules bz2, lzma, tarfile and zipfile. * Change the value of the mode attribute of GzipFile from integer (1 or 2) to string ('rb' or 'wb'). * Change the value of the mode attribute of ZipExtFile from 'r' to 'rb'.
* gh-102190: Add additional zipfile `pwd=` arg docstrings (gh-102195)Deborah2024-03-311-3/+6
| | | | | | | | This just documents the parameter that already exists. --------- Co-authored-by: Gregory P. Smith <greg@krypto.org> Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
* gh-117084: Fix ZIP file extraction for directory entry names with ↵Serhiy Storchaka2024-03-221-1/+9
| | | | backslashes on Windows (GH-117129)
* gh-106531: Refresh zipfile._path with zipp 3.18. (#116835)Jason R. Coombs2024-03-142-37/+140
| | | | | * gh-106531: Refresh zipfile._path with zipp 3.18. * Add blurb
* gh-67837, gh-112998: Fix dirs creation in concurrent extraction (GH-115082)Serhiy Storchaka2024-02-111-2/+6
| | | | | | | Avoid race conditions in the creation of directories during concurrent extraction in tarfile and zipfile. Co-authored-by: Samantha Hughes <shughes-uk@users.noreply.github.com> Co-authored-by: Peder Bergebakken Sundt <pbsds@hotmail.com>
* gh-113971: Make `zipfile.ZipInfo._compresslevel` public as `.compress_level` ↵Gregory P. Smith2024-01-121-9/+18
| | | | | | | | | | | (#113969) Make zipfile.ZipInfo.compress_level public. A property is used to retain the behavior of the ._compresslevel. People constructing zipfile.ZipInfo instances to pass into existing APIs to control per-file compression levels already treat this as public, there was never a reason for it not to be. I used the more modern name compress_level instead of compresslevel as the keyword argument on other ZipFile APIs is called to be consistent with compress_type and a general long term preference of not runningwordstogether without a separator in names.
* gh-109858: Protect zipfile from "quoted-overlap" zipbomb (GH-110016)Serhiy Storchaka2024-01-101-0/+12
| | | | | Raise BadZipFile when try to read an entry that overlaps with other entry or central directory.
* gh-112795: Allow `/` folder in a zipfile (#112932)AN Long2024-01-071-1/+1
| | | | | | Allow extraction (no-op) of a "/" folder in a zipfile, they are commonly added by some archive creation tools. Co-authored-by: Erlend E. Aasland <erlend@python.org> Co-authored-by: Gregory P. Smith <greg@krypto.org>
* gh-112578: Fix RuntimeWarning when running zipfile (GH-112579)Shantanu2023-12-032-77/+71
|
* gh-102956: Fix returning of empty byte strings after seek in zipfile … ↵Jokimax2023-10-241-5/+5
| | | | | (#103565) gh-102956: Fix returning of empty byte strings after seek in zipfile module. This was a regression in 3.12.0 due to a performance enhancement.
* gh-110715: Add missing import in zipfile (gh-110822)Kirill Podoprigora2023-10-141-0/+1
|
* gh-88233: zipfile: refactor _strip_extra (#102084)Jason R. Coombs2023-09-251-23/+37
| | | | | | | | | * Refactor zipfile._strip_extra to use higher level abstractions for extras instead of a heavy-state loop. * Add blurb * Remove _strip_extra and use _Extra.strip directly. * Use memoryview to avoid unnecessary copies while splitting Extras.
* gh-106752: Sync with zipp 3.16.2 (#106757)Jason R. Coombs2023-07-152-18/+53
| | | | | * gh-106752: Sync with zipp 3.16.2 * Add blurb
* gh-106752: Move zipfile._path into its own package (#106753)Jason R. Coombs2023-07-141-0/+0
| | | | | * gh-106752: Move zipfile._path into its own package so it may have supplementary behavior. * Add blurb
* gh-103861: Fix Zip64 extensions not being properly applied in some cases ↵Carey Metcalfe2023-05-161-15/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (#103863) Fix Zip64 extensions not being properly applied in some cases: Fixes an issue where adding a small file to a `ZipFile` object while forcing zip64 extensions causes an extra Zip64 record to be added to the zip, but doesn't update the `min_version` or file sizes in the primary central directory header. Also fixed an edge case in checking if zip64 extensions are required: This fixes an issue where if data requiring zip64 extensions was added to an unseekable stream without specifying `force_zip64=True`, zip64 extensions would not be used and a RuntimeError would not be raised when closing the file (even though the size would be known at that point). This would result in successfully writing corrupt zip files. Deciding if zip64 extensions are required outside of the `FileHeader` function means that both `FileHeader` and `_ZipWriteFile` will always be in sync. Previously, the `FileHeader` function could enable zip64 extensions without propagating that decision to the `_ZipWriteFile` class, which would then not correctly write the data descriptor record or check for errors on close. If anyone is actually using `ZipInfo.FileHeader` as a public API without explicitly passing True or False in for zip64, their own code may still be susceptible to that kind of bug unless they make a similar change to where the zip64 decision happens. Fixes #103861 --------- Co-authored-by: Gregory P. Smith <greg@krypto.org>
* GH-92184: Convert os.altsep to '/' in filenames when creating ZipInfo ↵Carey Metcalfe2023-05-111-0/+2
| | | | | | | | | objects (#92185) This causes the zipfile module to also consider the character defined by `os.altsep` (if there is one) to be a path separator and convert it to a forward slash, as defined by the zip specification. A logical no-op on all known platforms today as os.altsep is currently only set to a meaningful value on Windows (where it is "/").
* gh-86094: Add support for Unicode Path Extra Field in ZipFile (gh-102566)Yeojin Kim2023-04-051-13/+37
|
* gh-102209: Sync with zipp 3.15 moving complexity tests into dedicated module ↵Jason R. Coombs2023-02-251-1/+6
| | | | | (#102232) Sync with jaraco/zipp@757a4e1a.
* gh-101566: Sync with zipp 3.14. (GH-102018)Jason R. Coombs2023-02-201-3/+60
|
* gh-88233: zipfile: handle extras after a zip64 extra (GH-96161)Tim Hatch2023-02-201-0/+2
| | | | | | | | | Previously, any data _after_ the zip64 extra would be removed. With many new tests. Fixes #88233 Automerge-Triggered-By: GH:jaraco
* gh-101144: Allow open and read_text encoding to be positional. (#101145)Gregory P. Smith2023-01-201-5/+10
| | | | | The zipfile.Path open() and read_text() encoding parameter can be supplied as a positional argument without causing a TypeError again. 3.10.0b1 included a regression that made it keyword only. Documentation update included as users writing code to be compatible with a wide range of versions will need to consider this for some time.
* Improve zip64 limit error message (#95892)dmjohnsson232022-11-301-2/+2
|
* gh-98108: Add limited pickleability to zipfile.Path (GH-98109)Jason R. Coombs2022-11-261-1/+19
| | | | | | | | | | | | | | | * gh-98098: Move zipfile into a package. * Moved test_zipfile to a package * Extracted module for test_path. * Add blurb * Add jaraco as owner of zipfile.Path. * Synchronize with minor changes found at jaraco/zipp@d9e7f4352d. * gh-98108: Sync with zipp 3.9.1 adding pickleability.
* gh-98098: Create packages from zipfile and test_zipfile (gh-98103)Jason R. Coombs2022-11-263-0/+2585
* gh-98098: Move zipfile into a package. * Moved test_zipfile to a package * Extracted module for test_path. * Add blurb * Add jaraco as owner of zipfile.Path. * Synchronize with minor changes found at jaraco/zipp@d9e7f4352d.