From: Gil H. <gil...@ya...> - 2006-02-01 06:51:48
|
mmm, this could be the source to my problems, as my classpath and path env. vars are extremly large. I'll look into it. thanks! p.s. - if it is an open bug, it must be solved, it will prevent me from using Jython in mission critical systems... thanks. Gil Hoffer wrote: > I've been experiencing lately with some incredible hard bugs concerning > imports in Jython 2.2. (using JDK 1.5.0_04 on linux) > > I have a complicated system with lots and lots of jars. > When trying to execute "import sys", the import succeeds, but it imports > a weird "java package" object! it has no attributes except for a > __name__ attribute (which equals 'sys'). It has nothing to do with the > python builtin sys module. (e.g. invoking sys.path will cause an > AttributeError) > > When inspecting the object in the java debugger, I can get the 'sys' > object, and notice that it is a 'PyJavaPackage' object, but it has no > way to identify the original package. (actually, it contains a member > which might reveal the identity - but how disapointing, it is set to > null...) > > btw - I don't have ANY package named sys in my java classpath, nor in my > python pythonpath. > > When running the SAME code using Jython2.1 it works perfectly. > My system depends on P ython 2.2 features though (new style classes), so > I can't just revert to the old version. > > I have tried some other stuff, including retrieving the java package > using Package.getPackage("sys") which retruns null... This seems to be related to an import bug we noticed some time ago in our project (but didn't report back then .. sorry). What we found out is that Jython seems to import any directory as a module even if did not have __init__.py inside. Interestingly I can reproduce the problem both in Jython 2.1 and 2.2a1 but in former the problem seems to be less severe because there these bogus "modules" are not imported instead of the system modules. See examples below for more details. If I remember correctly this bug appeared also in some circumstances even if the directory was in the middle of the path (e.g. c:\foo\sys\bar) but I couldn't reproduce that now. Anyway, you should probably check do you have any directories named sys anywhere in your system. Btw, is this already a known bug or should I (or someone else) report it to the bug database at jython.sf.net? Cheers, .peke ### Demonstrating the problem both in Jython 2.1 and 2.2a1 ### Environment is Cygwin with Java installed into Windows side $ mkdir whatever $ jython Jython 2.2a1 on java1.5.0_04 (JIT: null) Type "copyright", "credits" or "license" for more information. >>> import whatever >>> dir(whatever) ['__name__'] >>> whatever.__name__ 'whatever' $ jython21 Jython 2.1 on java1.5.0 (JIT: null) Type "copyright", "credits" or "license" for more information. >>> import whatever >>> dir(whatever) ['__name__'] >>> whatever.__name__ 'whatever' $ rmdir whatever $ jython Jython 2.2a1 on java1.5.0_04 (JIT: null) Type "copyright", "credits" or "license" for more information. >>> import whatever Traceback (innermost last): File "<console>", line 1, in ? ImportError: no module named whatever ### In Jython 2.2a1 this seems to be more problematic as these ### bogus modules override the system modules. $ mkdir sys $ jython21 Jython 2.1 on java1.5.0 (JIT: null) Type "copyright", "credits" or "license" for more information. >>> import sys; sys.exit() $ jython Jython 2.2a1 on java1.5.0_04 (JIT: null) error importing site Traceback (innermost last): File "C:\jython-2.2a1\Lib\site.py", line 66, in ? AttributeError: java package 'sys' has no attribute 'modules' $ rmdir sys $ jython Jython 2.2a1 on java1.5.0_04 (JIT: null) Type "copyright", "credits" or "license" for more information. >>> import sys; sys.exit() --------------------------------- Bring words and photos together (easily) with PhotoMail - it's free and works with Yahoo! Mail. |
From: Frank W. <fwi...@gm...> - 2006-02-01 14:25:24
|
> Btw, is this already a known bug or should I (or someone else) report > it > to the bug database at jython.sf.net? > > Cheers, > .peke It isn't a known bug (at least I didn't know about it...) Please do report it so it doesn't get lost in the shuffle. Thanks, -Frank |
From: Frank W. <fwi...@gm...> - 2006-02-03 15:12:01
|
> PS: Any news about the beta? While researching the inclusion of PyXML into jython I found that I was going to have to pull in files from Python 2.3 to get the latest to work. We've already pulled in so many 2.3 libs, that I think it is time to just move the project to 2.3. If I don't move to 2.3, there will almost certainly be weird bugs from libs that where not meant to co-mingle. That doesn't even get into the support issues and confusion that will be caused by some of Jython acting like 2.2 and some acting like 2.3. The downside to all of this is that getting to a beta will take longer. I'll be putting up a projected roadmap pretty soon, but I don't have hard dates to give yet. -Frank |
From: Frank W. <fwi...@gm...> - 2006-02-10 18:19:47
|
> While researching the inclusion of PyXML into jython I found that I > was going to have to pull in files from Python 2.3 to get the latest > to work. We've already pulled in so many 2.3 libs, that I think it is > time to just move the project to 2.3. If I don't move to 2.3, there > will almost certainly be weird bugs from libs that where not meant to > co-mingle. That doesn't even get into the support issues and > confusion that will be caused by some of Jython acting like 2.2 and > some acting like 2.3. The downside to all of this is that getting to > a beta will take longer. I'll be putting up a projected roadmap > pretty soon, but I don't have hard dates to give yet. Hey all, Samuele Pedroni has expressed some reservations with this plan. He's talked me back into my previous position, which was to get a 2.2 out before attempting to go to 2.3, even though it does mean putting out a 2.2/2.3 hybrid, so I'm going to keep plugging away at a 2.2 release instead. The big plus is that I will get to a beta sooner. -Frank |