Message1853

Author juha_rantanen
Recipients
Date 2007-08-21.11:55:42
SpamBayes Score
Marked as misclassified
Message-id
In-reply-to
Content
Importing with __import__() function fails with standalone jython.jar (2.2rc3). It works fine, when jython from the basic installation is used. Java version used was 1.4.2_13.

Following code was used to verify the problem.

bug.py
======
try:
    classname = 'PackageTest'
    module = __import__('some.pack.test')
    clazz = getattr(module, classname)
    clazz().print('__import__ successful!')
except Exception, e:
    print e
    from some.pack.test import PackageTest
    PackageTest().print('from import successful!')

PackageTest.java
================
package some.pack.test;

public class PackageTest {	

	public PackageTest(){
	}
	
	public void print(String arg) {
		System.out.println(arg);
	}	
}

When the bug.py is executed like:
"java -cp test.jar;jython.jar org.python.util.jython bug.py" and "java -jar jython.jar bug.py" The outcome is:
no module named some
from import successful!

In -jar case the test.jar (attached) was set to classpath by adding it to Manifest.mf of jython.jar

So it seems that the package can be found from the environment, but the __import__ is not finding the package.
History
Date User Action Args
2008-02-20 17:17:59adminlinkissue1778514 messages
2008-02-20 17:17:59admincreate