Skip to content

Commit

Permalink
Thanks to Marc Downie for this patch that fixes
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
fwierzbicki committed Jan 22, 2009
1 parent dafb389 commit 3a577fa
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
8 changes: 8 additions & 0 deletions Lib/test/test_java_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -378,6 +382,10 @@ def test_adding_attributes(self):
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,
Expand Down
2 changes: 1 addition & 1 deletion src/org/python/core/packagecache/PackageManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ protected PyList basicDoDir(PyJavaPackage jpkg, boolean instantiate,
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));
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/org/python/core/packagecache/PathPackageManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ protected void doDir(PyList path, PyList ret, PyJavaPackage jpkg,
if (pkgCand) {
jpkg.addPackage(jname);
} else {
jpkg.addClass(jname, Py.findClass(jname));
jpkg.addClass(jname, Py.findClass(jpkg.__name__ + "." + jname));
}
}

Expand Down

0 comments on commit 3a577fa

Please sign in to comment.