Issue2171

classification
Title: jython returns NotImplemented for int.__pow__(x,y,None)
Type: behaviour Severity: normal
Components: Core Versions: Jython 2.7
Milestone:
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: alex.gronholm Nosy List: alex.gronholm, nneonneo, santa4nt
Priority: Keywords: patch

Created on 2014-06-21.23:18:03 by nneonneo, last changed 2015-04-14.14:20:55 by alex.gronholm.

Files
File name Uploaded Description Edit Remove
issue2171.patch santa4nt, 2014-06-22.17:37:36
issue2171.patch santa4nt, 2014-06-23.15:38:09
Messages
msg8780 (view) Author: Robert Xiao (nneonneo) Date: 2014-06-21.23:18:03
`int.__pow__(x, y, None)` returns NotImplemented, whereas `pow(x, y, None)` gives the correct result.

Sample session:

Jython 2.7b2 (default:a5bc0032cf79+, Apr 22 2014, 21:20:17) 
[Java HotSpot(TM) 64-Bit Server VM (Oracle Corporation)] on java1.8.0_05
Type "help", "copyright", "credits" or "license" for more information.
>>> pow(10,10,None)
10000000000L
>>> int.__pow__(10,10,None)
NotImplemented
>>> (10).__pow__(10, None)
NotImplemented
msg8786 (view) Author: Santoso Wijaya (santa4nt) Date: 2014-06-22.17:37:36
Caused by not checking for Py.None in PyInteger#___pow__(). Attaching patch.

Also, why are there two different implementations of pow()? __builtin__.pow() and PyInteger#pow(). Seems redundant to me.
msg9835 (view) Author: Alex Grönholm (alex.gronholm) Date: 2015-04-14.14:20:55
Thanks for the patch!

__builtin__.pow() provides the builtin pow() function, while PyInteger.__pow__() provides the specific implementation for PyInteger, so both are needed.

I applied your patch with one change worthy of notice: (10).__pow__(10L, None) returns NotImplemented on CPython 2.7.9 as well as Jython so I dropped the test for that.
History
Date User Action Args
2015-04-14 14:20:55alex.gronholmsetstatus: open -> closed
resolution: fixed
messages: + msg9835
2015-04-14 05:27:25alex.gronholmsetassignee: alex.gronholm
nosy: + alex.gronholm
2014-06-23 15:38:10santa4ntsetfiles: + issue2171.patch
2014-06-22 17:37:37santa4ntsetfiles: + issue2171.patch
keywords: + patch
messages: + msg8786
2014-06-22 05:29:54santa4ntsetnosy: + santa4nt
type: behaviour
2014-06-21 23:18:03nneonneocreate