diff -r c7c2b677ac1b -r 288d59cf3e2e Lib/test/test_int_jy.py --- a/Lib/test/test_int_jy.py Sat Jun 21 22:51:38 2014 -0600 +++ b/Lib/test/test_int_jy.py Mon Jun 23 08:37:05 2014 -0700 @@ -11,6 +11,12 @@ def test_type_matches(self): self.assert_(isinstance(1, types.IntType)) + def test_int_pow(self): + self.assertEquals(pow(10, 10, None), 10000000000L) + self.assertEquals(int.__pow__(10, 10, None), 10000000000L) + self.assertEquals((10).__pow__(10, None), 10000000000L) + self.assertEquals((10).__pow__(10L, None), 10000000000L) + def test_main(): test_support.run_unittest(IntTestCase) diff -r c7c2b677ac1b -r 288d59cf3e2e Lib/test/test_long_jy.py --- a/Lib/test/test_long_jy.py Sat Jun 21 22:51:38 2014 -0600 +++ b/Lib/test/test_long_jy.py Mon Jun 23 08:37:05 2014 -0700 @@ -26,6 +26,12 @@ # http://bugs.jython.org/issue1828 self.assertTrue(bool(MyLong(42))) + def test_long_pow(self): + self.assertEquals(pow(10L, 10L, None), 10000000000L) + self.assertEquals(long.__pow__(10L, 10L, None), 10000000000L) + self.assertEquals((10L).__pow__(10L, None), 10000000000L) + self.assertEquals((10L).__pow__(10, None), 10000000000L) + def test_main(): test_support.run_unittest(LongTestCase) diff -r c7c2b677ac1b -r 288d59cf3e2e src/org/python/core/PyFloat.java --- a/src/org/python/core/PyFloat.java Sat Jun 21 22:51:38 2014 -0600 +++ b/src/org/python/core/PyFloat.java Mon Jun 23 08:37:05 2014 -0700 @@ -714,7 +714,10 @@ final PyObject float___pow__(PyObject right, PyObject modulo) { if (!canCoerce(right)) { return null; - } else if (modulo != null) { + } + + modulo = (modulo == Py.None) ? null : modulo; + if (modulo != null) { throw Py.TypeError("pow() 3rd argument not allowed unless all arguments are integers"); } diff -r c7c2b677ac1b -r 288d59cf3e2e src/org/python/core/PyInteger.java --- a/src/org/python/core/PyInteger.java Sat Jun 21 22:51:38 2014 -0600 +++ b/src/org/python/core/PyInteger.java Mon Jun 23 08:37:05 2014 -0700 @@ -574,6 +574,7 @@ return null; } + modulo = (modulo == Py.None) ? null : modulo; if (modulo != null && !canCoerce(modulo)) { return null; } @@ -581,21 +582,17 @@ return _pow(getValue(), coerce(right), modulo, this, right); } - public PyObject __rpow__(PyObject left, PyObject modulo) { + @Override + public PyObject __rpow__(PyObject left) { if (!canCoerce(left)) { return null; } - - if (modulo != null && !canCoerce(modulo)) { - return null; - } - - return _pow(coerce(left), getValue(), modulo, left, this); + return _pow(coerce(left), getValue(), null, left, this); } @ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.int___rpow___doc) final PyObject int___rpow__(PyObject left) { - return __rpow__(left, null); + return __rpow__(left); } private static PyObject _pow(int value, int pow, PyObject modulo,// diff -r c7c2b677ac1b -r 288d59cf3e2e src/org/python/core/PyLong.java --- a/src/org/python/core/PyLong.java Sat Jun 21 22:51:38 2014 -0600 +++ b/src/org/python/core/PyLong.java Mon Jun 23 08:37:05 2014 -0700 @@ -659,9 +659,11 @@ return null; } + modulo = (modulo == Py.None) ? null : modulo; if (modulo != null && !canCoerce(right)) { return null; } + return _pow(getValue(), coerce(right), modulo, this, right); } @@ -675,6 +677,7 @@ if (!canCoerce(left)) { return null; } + return _pow(coerce(left), getValue(), null, left, this); }