From: <pj...@us...> - 2008-10-28 21:51:11
|
Revision: 5524 http://jython.svn.sourceforge.net/jython/?rev=5524&view=rev Author: pjenvey Date: 2008-10-28 21:47:35 +0000 (Tue, 28 Oct 2008) Log Message: ----------- fix float and complex's __pow__ not being exposed as binary ops Modified Paths: -------------- trunk/jython/Lib/test/test_complex_jy.py trunk/jython/Lib/test/test_float_jy.py trunk/jython/src/org/python/core/PyComplex.java trunk/jython/src/org/python/core/PyFloat.java Modified: trunk/jython/Lib/test/test_complex_jy.py =================================================================== --- trunk/jython/Lib/test/test_complex_jy.py 2008-10-28 07:58:42 UTC (rev 5523) +++ trunk/jython/Lib/test/test_complex_jy.py 2008-10-28 21:47:35 UTC (rev 5524) @@ -11,7 +11,14 @@ self.assertEqual(complex.__coerce__(1+1j, None), NotImplemented) self.assertRaises(TypeError, complex.__coerce__, None, 1+2j) + def test_pow(self): + class Foo(object): + def __rpow__(self, other): + return other ** 2 + # regression in 2.5 alphas + self.assertEqual((4+0j) ** Foo(), (16+0j)) + def test_main(): test_support.run_unittest(ComplexTest) Modified: trunk/jython/Lib/test/test_float_jy.py =================================================================== --- trunk/jython/Lib/test/test_float_jy.py 2008-10-28 07:58:42 UTC (rev 5523) +++ trunk/jython/Lib/test/test_float_jy.py 2008-10-28 21:47:35 UTC (rev 5524) @@ -78,7 +78,14 @@ def test_float_none(self): self.assertRaises(TypeError, float, None) + def test_pow(self): + class Foo(object): + def __rpow__(self, other): + return other ** 2 + # regression in 2.5 alphas + self.assertEqual(4.0 ** Foo(), 16.0) + def test_main(): test_support.run_unittest(FloatTestCase) Modified: trunk/jython/src/org/python/core/PyComplex.java =================================================================== --- trunk/jython/src/org/python/core/PyComplex.java 2008-10-28 07:58:42 UTC (rev 5523) +++ trunk/jython/src/org/python/core/PyComplex.java 2008-10-28 21:47:35 UTC (rev 5524) @@ -569,7 +569,7 @@ return complex___pow__(right, modulo); } - @ExposedMethod(defaults = "null") + @ExposedMethod(type = MethodType.BINARY, defaults = "null") final PyObject complex___pow__(PyObject right, PyObject modulo) { if (modulo != null) { throw Py.ValueError("complex modulo"); Modified: trunk/jython/src/org/python/core/PyFloat.java =================================================================== --- trunk/jython/src/org/python/core/PyFloat.java 2008-10-28 07:58:42 UTC (rev 5523) +++ trunk/jython/src/org/python/core/PyFloat.java 2008-10-28 21:47:35 UTC (rev 5524) @@ -468,7 +468,7 @@ return float___pow__(right, modulo); } - @ExposedMethod(defaults = "null") + @ExposedMethod(type = MethodType.BINARY, defaults = "null") final PyObject float___pow__(PyObject right, PyObject modulo) { if (!canCoerce(right)) return null; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |