From: <pj...@us...> - 2009-04-29 01:24:37
|
Revision: 6269 http://jython.svn.sourceforge.net/jython/?rev=6269&view=rev Author: pjenvey Date: 2009-04-29 01:24:23 +0000 (Wed, 29 Apr 2009) Log Message: ----------- fix int __mul__ assuming sequences wouldnt't overload __rmul__ fixes #1332 Modified Paths: -------------- trunk/jython/Lib/test/test_descr_jy.py trunk/jython/src/org/python/core/PyInteger.java Modified: trunk/jython/Lib/test/test_descr_jy.py =================================================================== --- trunk/jython/Lib/test/test_descr_jy.py 2009-04-28 17:35:27 UTC (rev 6268) +++ trunk/jython/Lib/test/test_descr_jy.py 2009-04-29 01:24:23 UTC (rev 6269) @@ -232,7 +232,16 @@ return 3 self.assertEqual(Foo() + Bar(), 3) + def test_int_mul(self): + # http://bugs.jython.org/issue1332 + class Foo(tuple): + def __rmul__(self, other): + return 'foo' + foo = Foo() + self.assertEqual(3.0 * foo, 'foo') + self.assertEqual(4 * foo, 'foo') + class InPlaceTestCase(unittest.TestCase): def test_iadd(self): Modified: trunk/jython/src/org/python/core/PyInteger.java =================================================================== --- trunk/jython/src/org/python/core/PyInteger.java 2009-04-28 17:35:27 UTC (rev 6268) +++ trunk/jython/src/org/python/core/PyInteger.java 2009-04-29 01:24:23 UTC (rev 6269) @@ -257,9 +257,6 @@ @ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.int___mul___doc) final PyObject int___mul__(PyObject right) { - if (right instanceof PySequence) - return ((PySequence) right).repeat(getValue()); - if (!canCoerce(right)) return null; int rightv = coerce(right); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |