Issue1197

classification
Title: Old style classes don't follow binop rules
Type: Severity: normal
Components: Core Versions:
Milestone:
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: pjenvey Nosy List: pjenvey, zyasoft
Priority: high Keywords:

Created on 2008-12-10.04:55:02 by pjenvey, last changed 2009-04-06.01:41:14 by pjenvey.

Messages
msg3899 (view) Author: Philip Jenvey (pjenvey) Date: 2008-12-10.04:55:01
Our binop methods return null to signal the binop "doesn't support the 
operation -- try alternatives". When we expose them as binary ops, those 
nulls are translated into Py.NotImplemented

The binop fast path looks for nulls, the slow path (_binop_rule) uses 
the exposed methods and looks for Py.NotImplemented

PyInstance still does not use exposed annotations, provides binops for 
all ops, and they all return null. This breaks _binop_rule:

Jython 2.5b0+ (trunk:5722:5725M, Dec 9 2008, 16:06:58) 
[Java HotSpot(TM) 64-Bit Server VM (Apple Inc.)] on java1.6.0_07
Type "help", "copyright", "credits" or "license" for more information.
>>> class Foo: pass
... 
>>> class Bar(object):
... 	def __radd__(self, other):
... 		return 3
... 
>>> print Foo() + Bar()
None

(We at least got a None, instead of null, because it went through the 
exposed version -- which is the Java integration version) 

i.e.
>>> # should return NotImplemented
>>> print types.InstanceType.__add__(Foo(), Bar())
None

We either need to expose PyInstance (a bunch more generated .classes) or 
think of another workaround
msg3900 (view) Author: Philip Jenvey (pjenvey) Date: 2008-12-10.04:55:54
This is the cause of at least one SymPy test failure:

__________ sympy/mpmath/tests/test_convert.py:test_conversion_methods 
__________
 File "/home/ondra/repos/sympy/sympy/mpmath/tests/test_convert.py",
line 112, in test_conversion_methods
   assert (y+x).ae(mpf('4.3'))
AttributeError: 'NoneType' object has no attribute 'ae'
msg4452 (view) Author: Philip Jenvey (pjenvey) Date: 2009-04-06.01:41:13
fixed in r6172 by converting PyInstance to exposed annotations

This added like 350KB of exposed descriptor bytecode =[ half of which are 
binops. oh well
History
Date User Action Args
2009-04-06 01:41:14pjenveysetstatus: open -> closed
resolution: fixed
messages: + msg4452
2009-04-04 02:42:15pjenveysetpriority: normal -> high
2009-03-14 14:26:00fwierzbickisetpriority: normal
2009-03-08 07:20:06zyasoftsetnosy: + zyasoft
2008-12-10 05:16:32pjenveysetcomponents: + Core
2008-12-10 04:55:54pjenveysetmessages: + msg3900
2008-12-10 04:55:02pjenveycreate