From: <fwi...@us...> - 2009-03-10 18:47:46
|
Revision: 6087 http://jython.svn.sourceforge.net/jython/?rev=6087&view=rev Author: fwierzbicki Date: 2009-03-10 18:47:33 +0000 (Tue, 10 Mar 2009) Log Message: ----------- Unit tests and fix for http://bugs.jython.org/issue1126 "ImportError raised for Java subpackages import". Thanks to boisgera for the report and for the unit testing code. Modified Paths: -------------- trunk/jython/Lib/test/test_classpathimporter.py trunk/jython/NEWS trunk/jython/src/org/python/core/imp.java Added Paths: ----------- trunk/jython/Lib/test/bug1126/ trunk/jython/Lib/test/bug1126/bug1126.jar Added: trunk/jython/Lib/test/bug1126/bug1126.jar =================================================================== (Binary files differ) Property changes on: trunk/jython/Lib/test/bug1126/bug1126.jar ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Modified: trunk/jython/Lib/test/test_classpathimporter.py =================================================================== --- trunk/jython/Lib/test/test_classpathimporter.py 2009-03-10 17:29:42 UTC (rev 6086) +++ trunk/jython/Lib/test/test_classpathimporter.py 2009-03-10 18:47:33 UTC (rev 6087) @@ -48,6 +48,12 @@ sys.path.append("Lib/test/bug1239.jar") import org.test403javapackage.test403 + # different from test_bug1239 in that only a Java package is imported, not + # a Java class. I'd also like to get rid of this checked in test jar. + def test_bug1126(self): + sys.path.append("Lib/test/bug1126/bug1126.jar") + import org.subpackage + def test_main(): test_support.run_unittest(ClasspathImporterTestCase) Modified: trunk/jython/NEWS =================================================================== --- trunk/jython/NEWS 2009-03-10 17:29:42 UTC (rev 6086) +++ trunk/jython/NEWS 2009-03-10 18:47:33 UTC (rev 6087) @@ -2,6 +2,7 @@ Jython 2.5 Bugs fixed (new numbering due to move to Roundup) + - [ 1126 ] ImportError raised for Java subpackages import - [ 1111 ] keyword arguments not supported on __import__ - [ 1567212 ] Jython $py.class bytecode doesn't include the .py's mtime - [ 1024 ] Jython $py.class bytecode doesn't include the .py's mtime Modified: trunk/jython/src/org/python/core/imp.java =================================================================== --- trunk/jython/src/org/python/core/imp.java 2009-03-10 17:29:42 UTC (rev 6086) +++ trunk/jython/src/org/python/core/imp.java 2009-03-10 18:47:33 UTC (rev 6087) @@ -635,9 +635,20 @@ } else { name = dottedName.substring(last_dot, dot); } + PyJavaPackage jpkg = null; + if (mod instanceof PyJavaPackage) { + jpkg = (PyJavaPackage)mod; + } + mod = import_next(mod, parentNameBuffer, name, fullName, fromlist); + if (jpkg != null && (mod == null || mod == Py.None)) { + // try again -- under certain circumstances a PyJavaPackage may + // have been added as a side effect of the last import_next + // attempt. see Lib/test_classpathimport.py#test_bug1126 + mod = import_next(jpkg, parentNameBuffer, name, fullName, fromlist); + } if (mod == null || mod == Py.None) { - throw Py.ImportError("No module named " + name); + throw Py.ImportError("No module named " + name); } last_dot = dot + 1; } while (dot != -1); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |