From: <pj...@us...> - 2009-05-29 02:34:53
|
Revision: 6418 http://jython.svn.sourceforge.net/jython/?rev=6418&view=rev Author: pjenvey Date: 2009-05-29 02:34:44 +0000 (Fri, 29 May 2009) Log Message: ----------- o fix comparison between Java objects of different types patch from Geoffrey French fixes #1338 o avoid test_nonexistent_import_with_security in odd environments like virtualenvs Modified Paths: -------------- trunk/jython/Lib/test/test_java_integration.py trunk/jython/NEWS trunk/jython/src/org/python/core/PyJavaType.java Modified: trunk/jython/Lib/test/test_java_integration.py =================================================================== --- trunk/jython/Lib/test/test_java_integration.py 2009-05-29 01:46:19 UTC (rev 6417) +++ trunk/jython/Lib/test/test_java_integration.py 2009-05-29 02:34:44 UTC (rev 6418) @@ -381,11 +381,36 @@ self.assertTrue(first_file <= first_date) self.assertTrue(first_date > first_file) self.assertTrue(first_date >= first_file) + + def test_equals(self): + # Test for bug #1338 + a = range(5) + + x = ArrayList() + x.addAll(a) + + y = Vector() + y.addAll(a) + + z = ArrayList() + z.addAll(range(1, 6)) + + self.assertTrue(x.equals(y)) + self.assertEquals(x, y) + self.assertTrue(not (x != y)) + + self.assertTrue(not x.equals(z)) + self.assertNotEquals(x, z) + self.assertTrue(not (x == z)) class SecurityManagerTest(unittest.TestCase): def test_nonexistent_import_with_security(self): + script = test_support.findfile("import_nonexistent.py") + home = os.path.realpath(sys.prefix) + if not os.path.commonprefix((home, os.path.realpath(script))) == home: + # script must lie within python.home for this test to work + return policy = test_support.findfile("python_home.policy") - script = test_support.findfile("import_nonexistent.py") self.assertEquals(subprocess.call([sys.executable, "-J-Dpython.cachedir.skip=true", "-J-Djava.security.manager", "-J-Djava.security.policy=%s" % policy, script]), 0) Modified: trunk/jython/NEWS =================================================================== --- trunk/jython/NEWS 2009-05-29 01:46:19 UTC (rev 6417) +++ trunk/jython/NEWS 2009-05-29 02:34:44 UTC (rev 6418) @@ -5,6 +5,10 @@ - [ 1354 ] core language failures in interactive interpreter - [ 1358 ] Simple pogram fails to parse in Jython 2.5rc3, but parses OK with CPython - [ 1357 ] no sys.executable when script runner is a relative link + - [ 1338 ] Comparing Java objects to each other fails when classes of values do not match + Fix file's repr with Windows paths + Fix urllib and urllib2 path handling on Windows + Fix r'\Jython25' not considered an abspath on Windows Jython 2.5.0 rc3 Bugs fixed Modified: trunk/jython/src/org/python/core/PyJavaType.java =================================================================== --- trunk/jython/src/org/python/core/PyJavaType.java 2009-05-29 01:46:19 UTC (rev 6417) +++ trunk/jython/src/org/python/core/PyJavaType.java 2009-05-29 02:34:44 UTC (rev 6418) @@ -510,16 +510,16 @@ @Override public PyObject __call__(PyObject o) { Object proxy = self.getJavaProxy(); - Object oAsJava = o.__tojava__(proxy.getClass()); - return proxy.equals(oAsJava) ? Py.True : Py.False; + Object oProxy = o.getJavaProxy(); + return proxy.equals(oProxy) ? Py.True : Py.False; } }); addMethod(new PyBuiltinMethodNarrow("__ne__", 1) { @Override public PyObject __call__(PyObject o) { Object proxy = self.getJavaProxy(); - Object oAsJava = o.__tojava__(proxy.getClass()); - return !proxy.equals(oAsJava) ? Py.True : Py.False; + Object oProxy = o.getJavaProxy(); + return !proxy.equals(oProxy) ? Py.True : Py.False; } }); addMethod(new PyBuiltinMethodNarrow("__hash__") { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |