Author mark.dickinson
Recipients chris.jerdonek, cvrebert, docs@python, ezio.melotti, mark.dickinson, mikehoy, rhettinger, terry.reedy
Date 2012-09-22.08:16:58
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1348301820.13.0.460725268872.issue12067@psf.upfronthosting.co.za>
In-reply-to
Content
> I determined that 'raise TypeError' and 'return NotImplemented' both
> result in the call of the reflected method

Are you sure?  raise TypeError *should* result in the operation being abandoned, with the reflected operation not tried.


Python 3.3.0rc2+ (default:3504cbb3e1d8, Sep 20 2012, 22:08:44) 
[GCC 4.2.1 (Apple Inc. build 5664)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> class A:
...     def __add__(self, other):
...         raise TypeError("Don't know how to add")
...     def __le__(self, other):
...         raise TypeError("Can't compare")
... 
[65945 refs]
>>> class B:
...     def __radd__(self, other):
...         return 42
...     def __ge__(self, other):
...         return False
... 
[66016 refs]
>>> A() <= B()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<stdin>", line 5, in __le__
TypeError: Can't compare
[66064 refs]
>>> A() + B()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<stdin>", line 3, in __add__
TypeError: Don't know how to add
[66065 refs]
History
Date User Action Args
2012-09-22 08:17:00mark.dickinsonsetrecipients: + mark.dickinson, rhettinger, terry.reedy, ezio.melotti, cvrebert, chris.jerdonek, docs@python, mikehoy
2012-09-22 08:17:00mark.dickinsonsetmessageid: <1348301820.13.0.460725268872.issue12067@psf.upfronthosting.co.za>
2012-09-22 08:16:59mark.dickinsonlinkissue12067 messages
2012-09-22 08:16:58mark.dickinsoncreate