packp3d crashes on imports outside packages

Bug #600027 reported by Craig Macomber
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Panda3D
Fix Released
Undecided
rdb

Bug Description

To reproduce:
Make this file structure:
test
    main.py
    someFolder
        test.py

in test.py put any import (such as "import os")
main.py can be empty

run packp3d, something like this:
Craig:Panda Craig$ panda3d /Developer/Panda3D/lib/direct/p3d/packp3d.p3d -o x.p3d -d test
Traceback (most recent call last):
  File "/Users/rdb/pandaworker/panda3d-1.7.0/built_cmu/direct/showbase/Messenger.py", line 352, in __taskChainDispatch
  File "/Users/rdb/pandaworker/panda3d-1.7.0/built_cmu/direct/showbase/Messenger.py", line 410, in __dispatch
  File "/Users/rdb/pandaworker/panda3d-1.7.0/built_cmu/direct/p3d/AppRunner.py", line 493, in __startIfReady
  File "VFSImporter", line 153, in load_module
  File "/Users/rdb/pandaworker/panda3d-1.7.0/built_cmu/direct/p3d/packp3d.py", line 219, in <module>
  File "/Users/rdb/pandaworker/panda3d-1.7.0/built_cmu/direct/p3d/packp3d.py", line 209, in makePackedApp
  File "/Users/rdb/pandaworker/panda3d-1.7.0/built_cmu/direct/p3d/Packager.py", line 2352, in endPackage
  File "/Users/rdb/pandaworker/panda3d-1.7.0/built_cmu/direct/p3d/Packager.py", line 403, in close
  File "/Users/rdb/pandaworker/panda3d-1.7.0/built_cmu/direct/p3d/Packager.py", line 493, in installMultifile
  File "/Users/rdb/pandaworker/panda3d-1.7.0/built_cmu/direct/showutil/FreezeTool.py", line 845, in done
  File "/Users/rdb/pandaworker/panda3d-1.7.0/built_cmu/direct/showutil/FreezeTool.py", line 919, in __loadModule
  File "/Users/rdb/pandaworker/panda3d-1.7.0/built_cmu/direct/showutil/FreezeTool.py", line 1358, in load_module
  File "/Users/rdb/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/modulefinder.py", line 305, in load_module
  File "/Users/rdb/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/modulefinder.py", line 414, in scan_code
  File "/Users/rdb/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/modulefinder.py", line 323, in _safe_import_hook
  File "/Users/rdb/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/modulefinder.py", line 125, in import_hook
  File "/Users/rdb/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/modulefinder.py", line 162, in determine_parent
KeyError: 'someFolder'
:task(error): Exception occurred in PythonTask Messenger-default
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/rdb/pandaworker/panda3d-1.7.0/built_cmu/direct/showbase/Messenger.py", line 352, in __taskChainDispatch
  File "/Users/rdb/pandaworker/panda3d-1.7.0/built_cmu/direct/showbase/Messenger.py", line 410, in __dispatch
  File "/Users/rdb/pandaworker/panda3d-1.7.0/built_cmu/direct/p3d/AppRunner.py", line 493, in __startIfReady
  File "VFSImporter", line 153, in load_module
  File "/Users/rdb/pandaworker/panda3d-1.7.0/built_cmu/direct/p3d/packp3d.py", line 219, in <module>
  File "/Users/rdb/pandaworker/panda3d-1.7.0/built_cmu/direct/p3d/packp3d.py", line 209, in makePackedApp
  File "/Users/rdb/pandaworker/panda3d-1.7.0/built_cmu/direct/p3d/Packager.py", line 2352, in endPackage
  File "/Users/rdb/pandaworker/panda3d-1.7.0/built_cmu/direct/p3d/Packager.py", line 403, in close
  File "/Users/rdb/pandaworker/panda3d-1.7.0/built_cmu/direct/p3d/Packager.py", line 493, in installMultifile
  File "/Users/rdb/pandaworker/panda3d-1.7.0/built_cmu/direct/showutil/FreezeTool.py", line 845, in done
  File "/Users/rdb/pandaworker/panda3d-1.7.0/built_cmu/direct/showutil/FreezeTool.py", line 919, in __loadModule
  File "/Users/rdb/pandaworker/panda3d-1.7.0/built_cmu/direct/showutil/FreezeTool.py", line 1358, in load_module
  File "/Users/rdb/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/modulefinder.py", line 305, in load_module
  File "/Users/rdb/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/modulefinder.py", line 414, in scan_code
  File "/Users/rdb/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/modulefinder.py", line 323, in _safe_import_hook
  File "/Users/rdb/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/modulefinder.py", line 125, in import_hook
  File "/Users/rdb/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/modulefinder.py", line 162, in determine_parent
KeyError: 'someFolder'
Successfully joined thread: 0
Failure on startup.
Craig:Panda Craig$

Any python file not at the root level or in a package that contains any import will cause an error like this as far as I know.

Revision history for this message
David Rose (droklaunchpad) wrote :

Noted. I will submit a fix. In the meantime, I expect this can be resolved by placing an empty __init__.py in someFolder, thus making someFolder a proper Python package.

Revision history for this message
Craig Macomber (craigm) wrote :

Yes, an empty __init__.py in the folder is a workaround (its what I'm using now). I forgot to mention that. Thanks!

Revision history for this message
Treeform (starplant) wrote : Re: [Bug 600027] Re: packp3d crashes on imports outside packages

I also run into this bug. Thought maybe its more like a feature not
to have orphan python files around.

On Tue, Jun 29, 2010 at 6:17 PM, Craig Macomber <CraigM@98115.net> wrote:
> Yes, an empty __init__.py in the folder is a workaround (its what I'm
> using now). I forgot to mention that. Thanks!
>
> --
> packp3d crashes on imports outside packages
> https://bugs.launchpad.net/bugs/600027
> You received this bug notification because you are subscribed to
> Panda3D.
>

Revision history for this message
rdb (rdb) wrote :

Can someone confirm if this was fixed in the latest packp3d_dev from https://runtime-dev.panda3d.org ?

Revision history for this message
rdb (rdb) wrote :

Finally fixed in 1.9, now shows the warning:

:Packager(warning): Cannot add Python file someFolder/test.py; not in package

Changed in panda3d:
assignee: nobody → rdb (rdb)
milestone: none → 1.9.1
status: New → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.