Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Explicit directories for zipfiles #49083

Closed
schuppenies mannequin opened this issue Jan 4, 2009 · 6 comments
Closed

Explicit directories for zipfiles #49083

schuppenies mannequin opened this issue Jan 4, 2009 · 6 comments
Labels
3.11 only security fixes stdlib Python modules in the Lib dir type-feature A feature request or enhancement

Comments

@schuppenies
Copy link
Mannequin

schuppenies mannequin commented Jan 4, 2009

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']

    @schuppenies
    Copy link
    Mannequin Author

    schuppenies mannequin commented Jan 4, 2009

    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.

    @schuppenies schuppenies mannequin added stdlib Python modules in the Lib dir type-feature A feature request or enhancement labels Jan 4, 2009
    @schmir
    Copy link
    Mannequin

    schmir mannequin commented Sep 23, 2009

    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

    @serhiy-storchaka
    Copy link
    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.

    @dignissimus
    Copy link
    Mannequin

    dignissimus mannequin commented Mar 27, 2022

    I'm looking into adding ZipFile.mkdir

    @dignissimus
    Copy link
    Mannequin

    dignissimus mannequin commented Mar 28, 2022

    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.

    @ethanfurman ethanfurman added the 3.11 only security fixes label Mar 28, 2022
    @ethanfurman
    Copy link
    Member

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

    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.11 only security fixes stdlib Python modules in the Lib dir type-feature A feature request or enhancement
    Projects
    Status: Done
    Development

    No branches or pull requests

    3 participants