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

zipfile: Allow reading duplicate filenames #45317

Closed
pysquared mannequin opened this issue Aug 15, 2007 · 4 comments
Closed

zipfile: Allow reading duplicate filenames #45317

pysquared mannequin opened this issue Aug 15, 2007 · 4 comments
Labels
stdlib Python modules in the Lib dir type-feature A feature request or enhancement

Comments

@pysquared
Copy link
Mannequin

pysquared mannequin commented Aug 15, 2007

BPO 1775025
Nosy @birkenfeld
Files
  • zipfile_56308.diff
  • zipfile_62920.diff: Updated + doc -> reST
  • 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 = <Date 2008-05-20.08:26:00.014>
    created_at = <Date 2007-08-15.22:37:50.000>
    labels = ['type-feature', 'library']
    title = 'zipfile: Allow reading duplicate filenames'
    updated_at = <Date 2008-05-20.08:25:59.857>
    user = 'https://bugs.python.org/pysquared'

    bugs.python.org fields:

    activity = <Date 2008-05-20.08:25:59.857>
    actor = 'georg.brandl'
    assignee = 'none'
    closed = True
    closed_date = <Date 2008-05-20.08:26:00.014>
    closer = 'georg.brandl'
    components = ['Library (Lib)']
    creation = <Date 2007-08-15.22:37:50.000>
    creator = 'pysquared'
    dependencies = []
    files = ['8173', '10382']
    hgrepos = []
    issue_num = 1775025
    keywords = ['patch']
    message_count = 4.0
    messages = ['53038', '67081', '67082', '67116']
    nosy_count = 3.0
    nosy_names = ['georg.brandl', 'pysquared', 'scott.dial']
    pr_nums = []
    priority = 'normal'
    resolution = 'accepted'
    stage = None
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue1775025'
    versions = ['Python 2.6']

    @pysquared
    Copy link
    Mannequin Author

    pysquared mannequin commented Aug 15, 2007

    Allow open() 'name' parameter to be a ZipInfo object, which allows opening archive members with duplicate filenames. Also allow read() 'name' parameter to be a ZipInfo object, as it calls open() directly.

    I got sent a zip file which had duplicate names in it, and the only way I could see to extract it using zipfile.py was to apply this patch.

    The infolist() and namelist() methods will return information for duplicate filenames, but the open() method takes only a name.

    This patch also updated the docs for zipfile.py.

    Python 2.1 -> 2.5 zipfile.py module does not have an open() method, but it would be trivial to backport this patch to enhance the read() method.

    # Test:
    # write() optionally warns, but still allows,
    # creating duplicate file names:
    import zipfile
    zf = zipfile.ZipFile('dupzip.zip', 'w')
    zf.debug = 1
    zf.writestr('dupname', 'Hello')
    zf.writestr('dupname', 'World')
    zf.close()
    # Print 'Hello' 'World'
    zfr = zipfile.ZipFile('dupzip.zip', 'r')
    for inf in zfr.infolist():
      print repr(zfr.read(inf))
    zfr.close()

    @pysquared pysquared mannequin added stdlib Python modules in the Lib dir labels Aug 15, 2007
    @benjaminp benjaminp added type-feature A feature request or enhancement labels May 19, 2008
    @scottdial
    Copy link
    Mannequin

    scottdial mannequin commented May 19, 2008

    In the patch you commented "why is 'filepos' computed next? It's never
    referenced." The answer is that back at r54152 (bpo-1121142) the method was
    rewrote removing any reference to 'filepos', but the patch author failed
    to remove that line. Please remove it.

    @pysquared
    Copy link
    Mannequin Author

    pysquared mannequin commented May 19, 2008

    Updated to latest revision, and converted documentation part of the
    patch to reST.

    Removed the line that pointlessly computes 'filepos', as requested by
    Scott Dial.

    (Please excuse my reST, I'm new to it and it's getting late).

    @birkenfeld
    Copy link
    Member

    Thanks, reviewed, added tests and committed as r63499.

    @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-feature A feature request or enhancement
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants