Issue2173

classification
Title: PyInteger#__(meth)__ does not play well with PyLong
Type: behaviour Severity: normal
Components: Core Versions: Jython 2.7
Milestone:
process
Status: closed Resolution: wont fix
Dependencies: Superseder:
Assigned To: Nosy List: pjenvey, santa4nt, zyasoft
Priority: Keywords:

Created on 2014-06-23.15:20:25 by santa4nt, last changed 2014-06-23.21:14:57 by zyasoft.

Messages
msg8794 (view) Author: Santoso Wijaya (santa4nt) Date: 2014-06-23.15:20:25
Observe:

Jython 2.7b3+ (default:68cf3c217269+, Jun 23 2014, 08:17:03) 
[Java HotSpot(TM) 64-Bit Server VM (Oracle Corporation)] on java1.7.0_60
Type "help", "copyright", "credits" or "license" for more information.
>>> (10).__pow__(10L)
NotImplemented
>>> (10).__add__(10L)
NotImplemented


This is caused by `canCoerce()` guards peppered throughout PyInteger method implementation, which simply test if the argument is an instance of PyInteger, which PyLong is not.
msg8799 (view) Author: Jim Baker (zyasoft) Date: 2014-06-23.16:07:31
Makes sense, yesterday I was seeing a somewhat related issues in terms of PyLong not playing well with PyInteger in java2py adapting.

Fortunately these are usually easy, to the point of trivial, to fix, once we have identified and started testing.

Note that is one example where CPython also doesn't get it right:

$ python
Python 2.7.5 (default, Mar  9 2014, 22:15:05)
[GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.0.68)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> (10).__add__(10L)
NotImplemented
msg8803 (view) Author: Santoso Wijaya (santa4nt) Date: 2014-06-23.17:17:12
Oh. By design, I guess.
msg8804 (view) Author: Jim Baker (zyasoft) Date: 2014-06-23.17:50:09
I think it's just an oversight in CPython 2.7. Clearly code like (10).__add__(10L) is not likely to be written by the average user, and while a lot of tests in core Python are good about not just looking at "average user" tests, they do occasionally miss things like this.
msg8808 (view) Author: Philip Jenvey (pjenvey) Date: 2014-06-23.18:36:09
Indeed by design so I wouldn't consider this not a bug/wontfix. 10 + 10L still works of course because it defers to 10L.__radd__(10)
msg8809 (view) Author: Philip Jenvey (pjenvey) Date: 2014-06-23.18:36:41
er I meant I wouldn't consider this a bug: it's not a bug/wontfix =]
msg8811 (view) Author: Jim Baker (zyasoft) Date: 2014-06-23.21:14:57
Sounds good, closing out
History
Date User Action Args
2014-06-23 21:14:57zyasoftsetstatus: open -> closed
resolution: wont fix
messages: + msg8811
2014-06-23 18:36:41pjenveysetmessages: + msg8809
2014-06-23 18:36:10pjenveysetnosy: + pjenvey
messages: + msg8808
2014-06-23 17:50:09zyasoftsetmessages: + msg8804
2014-06-23 17:17:13santa4ntsetmessages: + msg8803
2014-06-23 16:07:31zyasoftsetnosy: + zyasoft
messages: + msg8799
2014-06-23 15:20:25santa4ntcreate