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.extractall always raises an OSError after successfully unzipping all files #53418

Closed
aymill mannequin opened this issue Jul 5, 2010 · 6 comments
Closed

zipfile.extractall always raises an OSError after successfully unzipping all files #53418

aymill mannequin opened this issue Jul 5, 2010 · 6 comments
Labels
type-bug An unexpected behavior, bug, or error

Comments

@aymill
Copy link
Mannequin

aymill mannequin commented Jul 5, 2010

BPO 9172
Nosy @amauryfa, @ezio-melotti
Files
  • example_1.zip: WinZip 11.1, unencrypted.
  • 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 2010-07-29.14:00:49.042>
    created_at = <Date 2010-07-05.18:37:10.111>
    labels = ['type-bug']
    title = 'zipfile.extractall always raises an OSError after successfully unzipping all files'
    updated_at = <Date 2010-07-29.14:00:49.036>
    user = 'https://bugs.python.org/aymill'

    bugs.python.org fields:

    activity = <Date 2010-07-29.14:00:49.036>
    actor = 'BreamoreBoy'
    assignee = 'none'
    closed = True
    closed_date = <Date 2010-07-29.14:00:49.042>
    closer = 'BreamoreBoy'
    components = []
    creation = <Date 2010-07-05.18:37:10.111>
    creator = 'aymill'
    dependencies = []
    files = ['17873']
    hgrepos = []
    issue_num = 9172
    keywords = []
    message_count = 6.0
    messages = ['109346', '111551', '111815', '111902', '111906', '111927']
    nosy_count = 6.0
    nosy_names = ['amaury.forgeotdarc', 'ezio.melotti', 'ysj.ray', 'BreamoreBoy', 'aymill', 'terytkon']
    pr_nums = []
    priority = 'normal'
    resolution = 'duplicate'
    stage = None
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue9172'
    versions = ['Python 2.6', 'Python 3.1', 'Python 2.7', 'Python 3.2']

    @aymill
    Copy link
    Mannequin Author

    aymill mannequin commented Jul 5, 2010

    Tried it with a variety of unencrypted zips. Zipped with WinZip 11.1. Looks like it tries to unzip a second time after it completes the first unzip.

    Python 2.6.2 (release26-maint, Apr 19 2009, 01:56:41) 
    [GCC 4.3.3] on linux2
    Type "help", "copyright", "credits" or "license" for more information.
    >>> from zipfile import ZipFile
    >>> zip = ZipFile("example_1.zip")
    >>> zip.extractall()
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "/usr/lib/python2.6/zipfile.py", line 935, in extractall
        self.extract(zipinfo, path, pwd)
      File "/usr/lib/python2.6/zipfile.py", line 923, in extract
        return self._extract_member(member, path, pwd)
      File "/usr/lib/python2.6/zipfile.py", line 960, in _extract_member
        os.mkdir(targetpath)
    OSError: [Errno 17] File exists: '/home/andy/projects/codedropvalidator/testdata/example'
    >>>

    @aymill aymill mannequin added the type-bug An unexpected behavior, bug, or error label Jul 5, 2010
    @terytkon
    Copy link
    Mannequin

    terytkon mannequin commented Jul 25, 2010

    Hi!
    I encountered the same problem and I debugged it a bit..
    I think it not doing the entire unzipping again, but the problem is that the winzip packaged zip actually contains all file and directory entries and it fails trying to create already existing directory (because the dir has been created for the files that are in it).

    I tried a quick and dirty fix for the zipfile _extract_member method, which basically should fix the problem!

    So here I create the directory only if it is not already existing, to get those empty directories created inside the zip.

    zipfile:
    959: if member.filename[-1] == '/':
    <add> if not os.path.isdir(targetpath):
    960: os.mkdir(targetpath)

    @ysjray
    Copy link
    Mannequin

    ysjray mannequin commented Jul 28, 2010

    I didn't see this problem in py2.7 and py3k on debian linux. Is this windows specific or this bug has been fixed since py2.7?

    @terytkon
    Copy link
    Mannequin

    terytkon mannequin commented Jul 29, 2010

    Hi!

    I haven't tested this in linux or with python 2.7 so can't say for sure..

    However I would assume that the main issue is with the zipdate it self (So does it have those empty directories, which at least winzip creates) and then about how does the os.mkdir act with when trying to create already existing folder.

    Did you try it with the example_1.zip, which has those folders described in the zip centralrecord??

    Should I also try it out with linux?

    -Teemu

    @ysjray
    Copy link
    Mannequin

    ysjray mannequin commented Jul 29, 2010

    I found that this issue is duplicate with bpo-6050. And the bug has been fixed since 2.6.3.

    So this issue should be closed.

    @BreamoreBoy
    Copy link
    Mannequin

    BreamoreBoy mannequin commented Jul 29, 2010

    Closed as duplicate of bpo-6050.

    @BreamoreBoy BreamoreBoy mannequin closed this as completed Jul 29, 2010
    @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
    type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    0 participants