Skip to content

zipimport does not load ZIP files produced by GitHub #81095

Closed

Description

@VadimKantorov
BPO 36914
Nosy @tirkarthi
Superseder
  • bpo-5950: Make zipimport work with zipfile containing comments
  • 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 2019-05-14.09:49:41.726>
    created_at = <Date 2019-05-14.09:29:07.552>
    labels = ['3.7', 'type-bug', 'library']
    title = 'zipimport does not load ZIP files produced by GitHub'
    updated_at = <Date 2019-05-14.09:52:20.161>
    user = 'https://bugs.python.org/VadimKantorov'

    bugs.python.org fields:

    activity = <Date 2019-05-14.09:52:20.161>
    actor = 'xtreak'
    assignee = 'none'
    closed = True
    closed_date = <Date 2019-05-14.09:49:41.726>
    closer = 'SilentGhost'
    components = ['Library (Lib)']
    creation = <Date 2019-05-14.09:29:07.552>
    creator = 'Vadim Kantorov'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 36914
    keywords = []
    message_count = 3.0
    messages = ['342439', '342442', '342444']
    nosy_count = 3.0
    nosy_names = ['SilentGhost', 'Vadim Kantorov', 'xtreak']
    pr_nums = []
    priority = 'normal'
    resolution = 'duplicate'
    stage = 'resolved'
    status = 'closed'
    superseder = '5950'
    type = 'behavior'
    url = 'https://bugs.python.org/issue36914'
    versions = ['Python 3.7']

    Activity

    1. VadimKantorov commented on May 14, 2019

      VadimKantorovmannequin
      MannequinAuthor

      Python does not like source code zip-files produced by GitHub (zipimporting source from GitHub can be useful in some ad-hoc scripting scenarios e.g. I wanted to use it in Mozilla Iodide context)

      wget https://github.com/python/black/archive/master.zip
      python3.7 -m 'import zipimport; zipimport.zipimporter("master.zip")'
      # zipimport.ZipImportError: not a Zip file: 'master.zip'

      unzip master.zip
      zip -r master2.zip black-master
      python3.7 -m 'import zipimport; zipimport.zipimporter("master2.zip")'
      # OK

    2. added
      stdlibStandard Library Python modules in the Lib/ directory
      type-bugAn unexpected behavior, bug, or error
      on May 14, 2019
    3. SilentGhost commented on May 14, 2019

      SilentGhostmannequin
      Mannequin

      This is going to be fixed in 3.8 (see bpo-5950).

    4. tirkarthi commented on May 14, 2019

      @tirkarthi
      Member

      Seems to work on master branch though fails on 3.7.

      ➜  cpython git:(master) ✗ ./python.exe
      Python 3.8.0a4+ (heads/master:410b85a7f7, May 13 2019, 21:40:37)
      [Clang 7.0.2 (clang-700.1.81)] on darwin
      Type "help", "copyright", "credits" or "license" for more information.
      >>> import zipimport
      >>> zipimport.zipimporter("master.zip")
      <zipimporter object "master.zip/">
      >>> ^D
      ➜  cpython git:(master) ✗ python3.7
      Python 3.7.3 (v3.7.3:ef4ec6ed12, Mar 25 2019, 16:52:21)
      [Clang 6.0 (clang-600.0.57)] on darwin
      Type "help", "copyright", "credits" or "license" for more information.
      >>> import zipimport
      >>> zipimport.zipimporter("master.zip")
      Traceback (most recent call last):
        File "<stdin>", line 1, in <module>
      zipimport.ZipImportError: not a Zip file: 'master.zip'

      ➜ cpython git:(996859a) ✗ git checkout 5a5ce06
      Previous HEAD position was 996859a bpo-34790: [docs] Passing coroutines to asyncio.wait() can be confusing. (GH-9543)
      HEAD is now at 5a5ce06 bpo-5950: Support reading zips with comments in zipimport (bpo-9548)
      ➜ cpython git:(5a5ce06) ✗ make regen-importlib -s && make -s > /dev/null
      ➜ cpython git:(5a5ce06) ✗ ./python.exe -c 'import zipimport; zipimport.zipimporter("master.zip")'

      ➜  cpython git:(5a5ce064b3) ✗ git checkout 5a5ce064b3baadcb79605c5a42ee3d0aee57cdfc~1
      Previous HEAD position was 5a5ce064b3 bpo-5950: Support reading zips with comments in zipimport (#9548)
      HEAD is now at 996859a90d bpo-34790: [docs] Passing coroutines to asyncio.wait() can be confusing. (GH-9543)
      ➜  cpython git:(996859a90d) ✗ make regen-importlib -s && make -s > /dev/null
      ➜  cpython git:(996859a90d) ✗ ./python.exe -c 'import zipimport; zipimport.zipimporter("master.zip")'
      Traceback (most recent call last):
        File "<frozen zipimport>", line 89, in __init__
      KeyError: 'master.zip'
      
      During handling of the above exception, another exception occurred:
      
      Traceback (most recent call last):
        File "<string>", line 1, in <module>
        File "<frozen zipimport>", line 91, in __init__
        File "<frozen zipimport>", line 366, in _read_directory
      zipimport.ZipImportError: not a Zip file: 'master.zip'

      Bisecting tells me it could have been fixed with 5a5ce06 (bpo-5950) in 3.8 . Can you please try with a 3.8 release? Download 3.8 alpha 4 : https://www.python.org/downloads/release/python-380a4/

    5. 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.7 (EOL)end of lifestdlibStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or error

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions