From: <zy...@us...> - 2009-04-21 02:37:32
|
Revision: 6248 http://jython.svn.sourceforge.net/jython/?rev=6248&view=rev Author: zyasoft Date: 2009-04-21 02:37:28 +0000 (Tue, 21 Apr 2009) Log Message: ----------- Fixes #1317 - PyTuple#equals should only compare if the other obj is a List, but not a PyList, so as to balance both the Java and Python semantics. Modified Paths: -------------- trunk/jython/Lib/test/test_list_jy.py trunk/jython/src/org/python/core/PyTuple.java Modified: trunk/jython/Lib/test/test_list_jy.py =================================================================== --- trunk/jython/Lib/test/test_list_jy.py 2009-04-20 17:47:43 UTC (rev 6247) +++ trunk/jython/Lib/test/test_list_jy.py 2009-04-21 02:37:28 UTC (rev 6248) @@ -41,6 +41,9 @@ self.assertEquals(glmt.silly, "spam") glmt['my-key'] self.assertEquals(glmt.silly, "eggs") + + def test_tuple_equality(self): + self.assertEqual([(1,), [1]].count([1]), 1) # http://bugs.jython.org/issue1317 def test_main(): test.test_support.run_unittest(ListTestCase) Modified: trunk/jython/src/org/python/core/PyTuple.java =================================================================== --- trunk/jython/src/org/python/core/PyTuple.java 2009-04-20 17:47:43 UTC (rev 6247) +++ trunk/jython/src/org/python/core/PyTuple.java 2009-04-21 02:37:28 UTC (rev 6248) @@ -467,7 +467,7 @@ public boolean equals(Object o) { if (o instanceof PyTuple) { return Arrays.equals(array, ((PyTuple) o).array); - } else if (o instanceof List) { + } else if (o instanceof List && !(o instanceof PyList)) { return o.equals(this); } return false; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |