From: Samuele P. <pe...@in...> - 2000-10-27 12:26:07
|
Hi. Let's consider the following module/pkg/dir hierarchy: TOP/ a.py p0/ __init__.py x.py y.py p1/ __init__.py z.py all python files just contain: print __name__ except a.py: import p0.x print __name__ and x.py: import y import p1.z print __name__ (0) If one executes a.py from TOP with CPython 1.5/1.6/2.0 everything works fine. (1) Jython instead fails to locate p1 relative to x package (stmt import p1.z in x.py). Built-in Package Support in Python 1.5 ( http://www.python.org/doc/essays/packages.html ) is not explicit about loading packages relative to modules in pkgs, it only speaks about module (but pkgs "are" modules) rel. import, in any case CPython behaviour is to find p1 package relative to x package p0 completing import p1.z in x.py. So jython seems buggy in this respect. Notice that jython correctly locate y. (2) If one compiles a.py with jythonc and the --deep option, p0.y will not be compiled. The relative import rule is ignored by jythonc. In my opinion this is a bug, and I know how possibly fix this. Both bugs are better solved in the "grand" *loading cleanup... (a little note) Differently from jython, jythonc follows the proposed precedence py > java. For the rest (java loading) it uses the org.python.core runtime. Is that true? Remarks are welcome. regards, Samuele |