I seem to be getting a ‘BadZipfile’ error when I try to execute the following against any zip file.
zipped_path = './test.zip'
z = zipfile.ZipFile(zipped_path)
Gives the following -
Traceback (most recent call last):
File "zip.py", line 5, in <module>
File "/etc/rocket/python-2017-04-12-py27/lib/python2.7/pdb.py", line 1238, in run
Pdb().run(statement, globals, locals)
File "/etc/rocket/python-2017-04-12-py27/lib/python2.7/bdb.py", line 400, in run
exec cmd in globals, locals
File "<string>", line 1, in <module>
File "/test_python/zipfile.py", line 766, in __init__
File "/test_python/zipfile.py", line 807, in _RealGetContents
raise BadZipfile, "File is not a zip file"
zipfile.BadZipfile: File is not a zip file
Here is some info about my environment -
The same zip file (test.zip) is read properly with Rocket’s unzip under USS. I looked into why zipfile was throwing the error and it looks like its comparing a string that its reading from ‘test.zip’ that is represented as ASCII with a string hardcoded in zipfile that is represented as EBCDIC. Here is some output from the debugger that illustrates what I mean -
(Pdb) b zipfile:219
Breakpoint 1 at /test_python/zipfile.py:219
-> if (len(data) == sizeEndCentDir and
Any recommendations on how I can fix this?
Have you tried with the newer port Python 2.7.13 ?
This works with ASCII internally rather than with EBCDIC.
There is a chance that this fixes the problem.
Thanks, that worked!