From: <pj...@us...> - 2009-09-09 03:45:49
|
Revision: 6769 http://jython.svn.sourceforge.net/jython/?rev=6769&view=rev Author: pjenvey Date: 2009-09-09 03:45:43 +0000 (Wed, 09 Sep 2009) Log Message: ----------- fix __cmp__ specifying the wrong array type to lookup_where triggering an ArrayStoreException in some cases fixes #1382 Modified Paths: -------------- trunk/jython/Lib/test/test_cmp_jy.py trunk/jython/NEWS trunk/jython/src/templates/object.derived Modified: trunk/jython/Lib/test/test_cmp_jy.py =================================================================== --- trunk/jython/Lib/test/test_cmp_jy.py 2009-09-09 03:24:04 UTC (rev 6768) +++ trunk/jython/Lib/test/test_cmp_jy.py 2009-09-09 03:45:43 UTC (rev 6769) @@ -1,7 +1,18 @@ "Tests for cmp() compatibility with CPython" +import UserDict import unittest from test import test_support +class CmpGeneralTestCase(unittest.TestCase): + + def test_type_crash(self): + # Used to throw ArrayStoreException: + # http://bugs.jython.org/issue1382 + class Configuration(object, UserDict.DictMixin): + pass + self.assertNotEqual(Configuration(), None) + + class UnicodeDerivedCmp(unittest.TestCase): "Test for http://bugs.jython.org/issue1889394" def testCompareWithString(self): @@ -14,6 +25,7 @@ class B(unicode): pass self.assertEqual(A(), B()) + class LongDerivedCmp(unittest.TestCase): def testCompareWithString(self): class Test(long): @@ -21,6 +33,7 @@ self.assertNotEqual(Test(0), 'foo') self.assertTrue('foo' in [Test(12), 'foo']) + class IntStrCmp(unittest.TestCase): def testIntStrCompares(self): assert not (-1 > 'a') @@ -31,6 +44,7 @@ assert (-2 < 'a') assert not (-1 == 'a') + class CustomCmp(unittest.TestCase): def test___cmp___returns(self): class Foo(object): @@ -63,13 +77,16 @@ __eq__ = lambda self, other: True self.assertEqual(cmp(Foo(), Bar()), 1) + def test_main(): test_support.run_unittest( + CmpGeneralTestCase, UnicodeDerivedCmp, LongDerivedCmp, IntStrCmp, CustomCmp ) + if __name__ == '__main__': test_main() Modified: trunk/jython/NEWS =================================================================== --- trunk/jython/NEWS 2009-09-09 03:24:04 UTC (rev 6768) +++ trunk/jython/NEWS 2009-09-09 03:45:43 UTC (rev 6769) @@ -5,6 +5,8 @@ - [ 1079 ] fixed regression on issue: twisted.python.threadable module: missing attribute '_RLock' - [ 1461 ] assert statement should lookup AssertionError using getglobal - [ 1425 ] distutils/util.py assumes too much posix + - [ 1457 ] Cannot write an array in a file opened in r+b mode. + - [ 1382 ] __cmp__ on certain types raises ArrayStoreException Jython 2.5.1rc1 New Features Modified: trunk/jython/src/templates/object.derived =================================================================== --- trunk/jython/src/templates/object.derived 2009-09-09 03:24:04 UTC (rev 6768) +++ trunk/jython/src/templates/object.derived 2009-09-09 03:45:43 UTC (rev 6769) @@ -99,7 +99,7 @@ public int __cmp__(PyObject other) { PyType self_type=getType(); - PyType[] where_type = new PyType[1]; + PyObject[] where_type = new PyObject[1]; PyObject impl = self_type.lookup_where("__cmp__", where_type); // Full Compatibility with CPython __cmp__: // If the derived type don't override __cmp__, the This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |