This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: zipimport does not load ZIP files produced by GitHub
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.7
process
Status: closed Resolution: duplicate
Dependencies: Superseder: Make zipimport work with zipfile containing comments
View: 5950
Assigned To: Nosy List: SilentGhost, Vadim Kantorov, xtreak
Priority: normal Keywords:

Created on 2019-05-14 09:29 by Vadim Kantorov, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Messages (3)
msg342439 - (view) Author: Vadim Kantorov (Vadim Kantorov) Date: 2019-05-14 09:29
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
msg342442 - (view) Author: SilentGhost (SilentGhost) * (Python triager) Date: 2019-05-14 09:49
This is going to be fixed in 3.8 (see #5950).
msg342444 - (view) Author: Karthikeyan Singaravelan (xtreak) * (Python committer) Date: 2019-05-14 09:52
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:(996859a90d) ✗ git checkout 5a5ce064b3baadcb79605c5a42ee3d0aee57cdfc
Previous HEAD position was 996859a90d bpo-34790: [docs] Passing coroutines to asyncio.wait() can be confusing. (GH-9543)
HEAD is now at 5a5ce064b3 bpo-5950: Support reading zips with comments in zipimport (#9548)
➜  cpython git:(5a5ce064b3) ✗ make regen-importlib -s && make -s > /dev/null
➜  cpython git:(5a5ce064b3) ✗ ./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 5a5ce064b3baadcb79605c5a42ee3d0aee57cdfc (issue5950) 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/
History
Date User Action Args
2022-04-11 14:59:15adminsetgithub: 81095
2019-05-14 09:52:20xtreaksetnosy: + xtreak
messages: + msg342444
2019-05-14 09:49:41SilentGhostsetstatus: open -> closed

superseder: Make zipimport work with zipfile containing comments

nosy: + SilentGhost
messages: + msg342442
resolution: duplicate
stage: resolved
2019-05-14 09:29:07Vadim Kantorovcreate