Issue1861973

classification
Title: importing modules from class broken
Type: Severity: normal
Components: None Versions:
Milestone:
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: pjenvey Nosy List: pjenvey, tristanlk
Priority: normal Keywords:

Created on 2008-01-02.05:09:49 by tristanlk, last changed 2008-01-04.00:20:34 by pjenvey.

Messages
msg2045 (view) Author: tristan (tristanlk) Date: 2008-01-02.05:09:49
once some classes have been compiled (mainly __init__) they no longer work as expected.

example (sorry if this is hard to follow):

$ ls
demo.py  test
$ ls test/
down  __init__.py
$ ls test/down/
__init__.py
$ cat demo.py 
import test
import test.down
print test.__file__
print test.__path__
print test.down.__file__
print test.down.__path__
test.down.test()
$ cat test/__init__.py 
$ cat test/down/__init__.py 
import traceback
def test():
    traceback.print_stack()
$ jython demo.py 
test/__init__.py
['test']
test/down/__init__.py
['test/down']
  File "demo.py", line 7, in ?
    test.down.test()
  File "test/down/__init__.py", line 3, in test
    traceback.print_stack()
$ jython demo.py 
__init__.py
['test']
test/__init__.py
['test/down']
  File "demo.py", line 7, in ?
    test.down.test()
  File "test/__init__.py", line 3, in test

you'll notice the first run works fine (which is running from source), but the second time it fails (when it's trying to load from the $py.class).
msg2046 (view) Author: tristan (tristanlk) Date: 2008-01-02.05:13:05
see patch 1861974 for fix.

there are also minor printing problems here, since the python outputs the entire path.

$ python demo.py 
/home/tristan/tmp/test/__init__.pyc
['/home/tristan/tmp/test']
/home/tristan/tmp/test/down/__init__.pyc
['/home/tristan/tmp/test/down']
  File "demo.py", line 9, in ?
    test.down.test()
  File "/home/tristan/tmp/test/down/__init__.py", line 3, in test
    traceback.print_stack()
msg2047 (view) Author: Philip Jenvey (pjenvey) Date: 2008-01-02.07:55:43
this is trunk (according to your patch)

I own this since I've been playing around in there lately for chdir. I might have caused it
msg2048 (view) Author: Philip Jenvey (pjenvey) Date: 2008-01-04.00:20:34
applied your patch in r3962

the absolute path problem is due to the path entry from sys.path used to import these files being '' in jython instead of the absolute path, like in CPython. I've fixed that in r3963, thanks!
History
Date User Action Args
2008-01-02 05:09:49tristanlkcreate