You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
zipimport does not load ZIP files produced by GitHub #81095
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=Noneclosed_at=<Date2019-05-14.09:49:41.726>created_at=<Date2019-05-14.09:29:07.552>labels= ['3.7', 'type-bug', 'library']
title='zipimport does not load ZIP files produced by GitHub'updated_at=<Date2019-05-14.09:52:20.161>user='https://bugs.python.org/VadimKantorov'
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)
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 996859abpo-34790: [docs] Passing coroutines to asyncio.wait() can be confusing. (GH-9543)
HEAD is now at 5a5ce06bpo-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_directoryzipimport.ZipImportError: not a Zip file: 'master.zip'
Activity
VadimKantorov commentedon May 14, 2019
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
SilentGhost commentedon May 14, 2019
This is going to be fixed in 3.8 (see bpo-5950).
tirkarthi commentedon May 14, 2019
Seems to work on master branch though fails on 3.7.
➜ 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/