From: <fwi...@us...> - 2009-01-22 04:16:49
|
Revision: 5957 http://jython.svn.sourceforge.net/jython/?rev=5957&view=rev Author: fwierzbicki Date: 2009-01-22 04:16:47 +0000 (Thu, 22 Jan 2009) Log Message: ----------- Thanks to Marc Downie for this patch that fixes http://bugs.jython.org/issue1230 importing with '*' from java packages does not work with 2.5b1. Also added a test to test_java_integration.py. Modified Paths: -------------- trunk/jython/Lib/test/test_java_integration.py trunk/jython/src/org/python/core/packagecache/PackageManager.java trunk/jython/src/org/python/core/packagecache/PathPackageManager.java Modified: trunk/jython/Lib/test/test_java_integration.py =================================================================== --- trunk/jython/Lib/test/test_java_integration.py 2009-01-22 02:21:08 UTC (rev 5956) +++ trunk/jython/Lib/test/test_java_integration.py 2009-01-22 04:16:47 UTC (rev 5957) @@ -20,6 +20,10 @@ from org.python.core.util import FileUtil from org.python.tests import BeanImplementation, Child, Listenable, CustomizableMapHolder +#Just for test_import_star +#java.util.regex was chosen for its small number of classes to reduce the pollution. +from java.util.regex import * + class InstantiationTest(unittest.TestCase): def test_cant_instantiate_abstract(self): self.assertRaises(TypeError, Component) @@ -378,6 +382,10 @@ self.assertEquals(7, m.initial) self.assertEquals(None, m.nonexistent, "Nonexistent fields should be passed on to the Map") + def test_import_star(self): + #Depends on "from java.util.regex import *" at the top. + x = Pattern.compile("foo") + self.assertEquals(x.flags(), 0) def test_main(): test_support.run_unittest(InstantiationTest, Modified: trunk/jython/src/org/python/core/packagecache/PackageManager.java =================================================================== --- trunk/jython/src/org/python/core/packagecache/PackageManager.java 2009-01-22 02:21:08 UTC (rev 5956) +++ trunk/jython/src/org/python/core/packagecache/PackageManager.java 2009-01-22 04:16:47 UTC (rev 5957) @@ -107,7 +107,7 @@ for (PyObject pyname : cls.keys().asIterable()) { if (!dict.has_key(pyname)) { String name = pyname.toString(); - jpkg.addClass(name, Py.findClass(name)); + jpkg.addClass(name, Py.findClass(jpkg.__name__ + "." + name)); } } Modified: trunk/jython/src/org/python/core/packagecache/PathPackageManager.java =================================================================== --- trunk/jython/src/org/python/core/packagecache/PathPackageManager.java 2009-01-22 02:21:08 UTC (rev 5956) +++ trunk/jython/src/org/python/core/packagecache/PathPackageManager.java 2009-01-22 04:16:47 UTC (rev 5957) @@ -164,7 +164,7 @@ if (pkgCand) { jpkg.addPackage(jname); } else { - jpkg.addClass(jname, Py.findClass(jname)); + jpkg.addClass(jname, Py.findClass(jpkg.__name__ + "." + jname)); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |