python / cpython

The Python programming language
https://www.python.org
Other
63.38k stars 30.35k forks source link

Add zip64 support to shutil #61391

Closed 338b8e9a-90a1-4f02-9484-4aaf9a966b09 closed 9 years ago

338b8e9a-90a1-4f02-9484-4aaf9a966b09 commented 11 years ago
BPO 17189
Nosy @pitrou, @tarekziade, @hynek, @serhiy-storchaka
Superseder
  • bpo-17201: Use allowZip64=True by default
  • Files
  • shutil_zip64.patch
  • shutil_zip64_by_default.patch
  • shutil_zip64_by_default.patch: Added documentation.
  • 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: ```python assignee = None closed_at = created_at = labels = ['type-feature', 'library'] title = 'Add zip64 support to shutil' updated_at = user = 'https://bugs.python.org/williammallard' ``` bugs.python.org fields: ```python activity = actor = 'serhiy.storchaka' assignee = 'none' closed = True closed_date = closer = 'serhiy.storchaka' components = ['Library (Lib)'] creation = creator = 'william.mallard' dependencies = [] files = ['29045', '29060', '29063'] hgrepos = [] issue_num = 17189 keywords = ['patch'] message_count = 8.0 messages = ['181941', '182009', '182018', '182027', '182032', '182043', '182052', '182059'] nosy_count = 5.0 nosy_names = ['pitrou', 'tarek', 'william.mallard', 'hynek', 'serhiy.storchaka'] pr_nums = [] priority = 'normal' resolution = 'out of date' stage = 'resolved' status = 'closed' superseder = '17201' type = 'enhancement' url = 'https://bugs.python.org/issue17189' versions = ['Python 3.4'] ```

    338b8e9a-90a1-4f02-9484-4aaf9a966b09 commented 11 years ago

    This patch enables creation of 64-bit zip files via make_archive().

    make_archive uses ZipFile to create zip files. ZipFile already supports creation of 64-bit archives via a kwarg, but make_archive hard-codes it to 32-bit. This patch exposes the option in a backwards compatible way.

    pitrou commented 11 years ago

    Would there be a way to automatically switch the flag as necessary? (i.e. when writing more than 2GB, I guess)

    serhiy-storchaka commented 11 years ago

    Would there be a way to automatically switch the flag as necessary? (i.e. when writing more than 2GB, I guess)

    Yes, there is a special flag for this in zipfile. It is named allowZip64.

    The only reason to use allowZip64=False is when you expect to unzip a zipfile with a tool which doesn't support zip64 (PKUNZIP.EXE for DOS?) and you want to keep yourself from unintentional zipping a file larger than 2 GiB.

    Perhaps sometime we should to change the default value for allowZip64 from False to True.

    pitrou commented 11 years ago

    Yes, there is a special flag for this in zipfile. It is named allowZip64.

    Then I think shutil should set allowZip64 to True by default. People who want fine-grained control over the zipfile's characteristics can still use the zipfile module directly.

    serhiy-storchaka commented 11 years ago

    Agree.

    338b8e9a-90a1-4f02-9484-4aaf9a966b09 commented 11 years ago

    Ok, here's a patch that makes zip64 the default in make_archive() when format='zip'.

    I also agree that ZipFile should set allowZip64=True by default. (PKZIP has supported zip64 since 2001!)

    serhiy-storchaka commented 11 years ago

    This should be reflected in the documentation.

    338b8e9a-90a1-4f02-9484-4aaf9a966b09 commented 11 years ago

    Documentation added. See attached.