I’m having an issue with the ZipFile python module. I’ve got code that extracts files from a zip file, which works when I run the script using python, but when I pack it into a .p3d it gives me this error:
:task(error): Exception occurred in PythonTask Extract Model
Traceback (most recent call last):
File "/Users/rdb/pandaworker/panda3d-1.7.0/built_cmu/direct/p3d/AppRunner.py", line 411, in run
File "/Users/rdb/pandaworker/panda3d-1.7.0/built_cmu/direct/task/Task.py", line 496, in run
File "/Users/rdb/pandaworker/panda3d-1.7.0/built_cmu/direct/task/Task.py", line 454, in step
File "/Users/aaron/Projects/MAW/BOT/BOTApps/Shelves/Connection.py", line 76, in extractModelTask
modelZipFile = zipfile.ZipFile(filePath, 'r')
File "/Users/rdb/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/zipfile.py", line 693, in __init__
File "/Users/rdb/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/zipfile.py", line 713, in _GetContents
File "/Users/rdb/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/zipfile.py", line 723, in _RealGetContents
File "/Users/rdb/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/zipfile.py", line 201, in _EndRecData
File "/Users/rdb/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/zipfile.py", line 149, in _EndRecData64
struct.error: unpack requires a string argument of length 20
Anyone have any ideas? The code that’s trowing this error is just the standard code to open a zipfile:
I’m downloading the zip file from the web to disk, so it’s not an issue with the file being inside the .p3d. The file downloads correctly, but ZipFile throws this error when I try to open it. The zip file itself is also o.k., since the script works when it’s not packaged in a .p3d. I’m not sure what the struct.error means and why it’s only coming up when the application is packaged.
One suggestion I have is to pack your p3d with the -D flag, and run it with the -i flag, so that you can inspect the python stack at the time of the crash (via pdb).
This might give some insight. You should be able to inspect the value that is being passed to unpack that is not a string argument of length 20, and see what it actually is.
When I run the .p3d in debug mode I get a bunch of type errors:
Attempt to register type HTTPChannel more than once!
Attempt to register type VirtualFile more than once!
...and a bunch more of these
Attempt to register type pset more than once!
Invalid TypeHandle index 37! Is memory corrupt?
Assertion failed: (rnode != (TypeRegistryNode *)NULL), function dec_memory_usage, file dtool/src/dtoolbase/typeHandle.cxx, line 96.
I’ve seen this error before when I’ve tried to use the debug mode, but I’m not sure what’s causing it. Maybe there’s a fix for this or another way to debug my ZipFile problem?
Hum, that sounds like trouble too. Sounds like both of these issues bear investigation. I’ll try to reproduce the zipfile issue locally. I’m not sure about the debug problem, though–maybe there’s something broken about the public distribution of packp3d? I’ll get that program and see if I can reproduce that problem as well.