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

python -mzipfile fails to add empty folders to created zip #66415

Closed
anntzer mannequin opened this issue Aug 17, 2014 · 6 comments
Closed

python -mzipfile fails to add empty folders to created zip #66415

anntzer mannequin opened this issue Aug 17, 2014 · 6 comments
Assignees
Labels
stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@anntzer
Copy link
Mannequin

anntzer mannequin commented Aug 17, 2014

BPO 22219
Nosy @serhiy-storchaka, @anntzer
Files
  • zipfile_add_dirs.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 = 'https://github.com/serhiy-storchaka'
    closed_at = <Date 2014-10-04.11:53:05.328>
    created_at = <Date 2014-08-17.17:53:45.452>
    labels = ['type-bug', 'library']
    title = 'python -mzipfile fails to add empty folders to created zip'
    updated_at = <Date 2014-10-04.11:53:05.327>
    user = 'https://github.com/anntzer'

    bugs.python.org fields:

    activity = <Date 2014-10-04.11:53:05.327>
    actor = 'serhiy.storchaka'
    assignee = 'serhiy.storchaka'
    closed = True
    closed_date = <Date 2014-10-04.11:53:05.328>
    closer = 'serhiy.storchaka'
    components = ['Library (Lib)']
    creation = <Date 2014-08-17.17:53:45.452>
    creator = 'Antony.Lee'
    dependencies = []
    files = ['36706']
    hgrepos = []
    issue_num = 22219
    keywords = ['patch']
    message_count = 6.0
    messages = ['225457', '225459', '225530', '226408', '227437', '228446']
    nosy_count = 3.0
    nosy_names = ['python-dev', 'serhiy.storchaka', 'Antony.Lee']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue22219'
    versions = ['Python 2.7', 'Python 3.4', 'Python 3.5']

    @anntzer
    Copy link
    Mannequin Author

    anntzer mannequin commented Aug 17, 2014

    Compare

    $ mkdir foo; zip -q foo{,}; unzip -l foo.zip
    Archive:  foo.zip
      Length      Date    Time    Name
    ---------  ---------- -----   

        0  2014-08-17 10:49   foo/
    

    --------- -------
    0 1 file

    and

    $ mkdir foo; python -mzipfile -c foo{.zip,}; unzip -l foo.zip
    Archive:  foo.zip
    warning [foo.zip]:  zipfile is empty

    A patch was posted by Ryan Wilson in related issue bpo-22201.

    @anntzer anntzer mannequin added the stdlib Python modules in the Lib dir label Aug 17, 2014
    @serhiy-storchaka serhiy-storchaka self-assigned this Aug 17, 2014
    @serhiy-storchaka serhiy-storchaka added the type-bug An unexpected behavior, bug, or error label Aug 17, 2014
    @serhiy-storchaka
    Copy link
    Member

    Directory entry should be added not only when directory is empty.

    See also bpo-20912.

    @serhiy-storchaka
    Copy link
    Member

    I think zipfile should add an entry for directories as zip tool does. Here is a patch. In additional it fixes zipfile -c for some corner cases (when arguments end with /, . or .. component).

    @serhiy-storchaka
    Copy link
    Member

    If there are no objections I'll commit the patch soon.

    @serhiy-storchaka
    Copy link
    Member

    Hmm, looks as I forgot to attach a patch.

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Oct 4, 2014

    New changeset 911da1072099 by Serhiy Storchaka in branch '2.7':
    Issue bpo-22219: The zipfile module CLI now adds entries for directories
    https://hg.python.org/cpython/rev/911da1072099

    New changeset 981d18930d6d by Serhiy Storchaka in branch '3.4':
    Issue bpo-22219: The zipfile module CLI now adds entries for directories
    https://hg.python.org/cpython/rev/981d18930d6d

    New changeset d61d2e5a0956 by Serhiy Storchaka in branch 'default':
    Issue bpo-22219: The zipfile module CLI now adds entries for directories
    https://hg.python.org/cpython/rev/d61d2e5a0956

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant