Skip to content

Explicit directories for zipfiles #49083

Description

@schuppenies
BPO 4833
Nosy @Yhg1s, @ethanfurman, @serhiy-storchaka, @dignissimus
PRs
  • bpo-4833: Add ZipFile.mkdir #32160
  • Files
  • test.zip
  • sam_ezeh.patch
  • 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:

    assignee = None
    closed_at = None
    created_at = <Date 2009-01-04.17:09:27.841>
    labels = ['type-feature', 'library', '3.11']
    title = 'Explicit directories for zipfiles'
    updated_at = <Date 2022-04-05.18:41:41.657>
    user = 'https://bugs.python.org/schuppenies'

    bugs.python.org fields:

    activity = <Date 2022-04-05.18:41:41.657>
    actor = 'ethan.furman'
    assignee = 'none'
    closed = False
    closed_date = None
    closer = None
    components = ['Library (Lib)']
    creation = <Date 2009-01-04.17:09:27.841>
    creator = 'schuppenies'
    dependencies = []
    files = ['14956', '50705']
    hgrepos = []
    issue_num = 4833
    keywords = ['patch']
    message_count = 6.0
    messages = ['79070', '93031', '176860', '416126', '416203', '416800']
    nosy_count = 9.0
    nosy_names = ['twouters', 'alanmcintyre', 'schmir', 'schuppenies', 'Arfrever', 'thijs', 'ethan.furman', 'serhiy.storchaka', 'sam_ezeh']
    pr_nums = ['32160']
    priority = 'normal'
    resolution = None
    stage = 'patch review'
    status = 'open'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue4833'
    versions = ['Python 3.11']

    Activity

    1. schuppenies commented on Jan 4, 2009

      schuppeniesmannequin
      MannequinAuthor

      We have an issue with the Python cheeseshop which is probably an issue
      with Python itself as well.

      When we create a zip file with standard linux tools ('zip os-zipped.zip
      *'), uploading it works fine. But if we use the zipfile module from
      Python and try to upload the result to the cheeseshop, we get this error
      message:

      " Error unpacking zipfile:[Errno 2] No such file or directory:
      u'/data/packagedocs/Pympler/_sources/index.txt'"

      Turns out that the Python-zipped version does not include explicit
      directories. The OS-zipped version contains "directory/,
      directory/asizeof.txt", the Python-zipped file only
      "directory/asizeof.txt". Digging deeper, Python has no way to explicitly
      add directories to a zip file.

      It would be useful to have an option which allows the explicit creation
      of directories inside of zip files. This would help when working with
      applications which do not create directories if they are not explicitly
      specified.

    2. added
      stdlibStandard Library Python modules in the Lib/ directory
      type-featureA feature request or enhancement
      on Jan 4, 2009
    3. schmir commented on Sep 23, 2009

      schmirmannequin
      Mannequin

      it looks like this is fixed in 2.6.2.

      I'm attaching a zipfile which cannot be extracted in 2.6.1

      Running
      python -c 'import zipfile; zipfile.ZipFile("test.zip").extractall()'
      in 2.6.2 however works.
      but you should not do that anyway because of bpo-6972

    4. serhiy-storchaka commented on Dec 3, 2012

      @serhiy-storchaka
      Member

      Actually now creating directories in zipfile is possible with ZipFile.writestr(special_zip_info, b''). However a special method (like ZipFile.mkdir(name)) can be useful.

    5. dignissimus commented on Mar 27, 2022

      dignissimusmannequin
      Mannequin

      I'm looking into adding ZipFile.mkdir

    6. dignissimus commented on Mar 28, 2022

      dignissimusmannequin
      Mannequin

      I've submitted the above patch. I created the ZipFile.mkdir function, created the necessary tests and wrote the documentation.

      I think it is ready for review.

    7. ethanfurman commented on Apr 5, 2022

      @ethanfurman
      Member

      New changeset 050a8f9 by Sam Ezeh in branch 'main':
      bpo-4833: Add ZipFile.mkdir (GH-32160)
      050a8f9

    8. transferred this issue fromon Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    No one assigned

      Labels

      3.11only security fixesstdlibStandard Library Python modules in the Lib/ directorytype-featureA feature request or enhancement

      Projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions