[ python-Bugs-847024 ] NotImplemented return value misinterpreted
in new classes
SourceForge.net
noreply at sourceforge.net
Fri Nov 21 21:39:43 EST 2003
Bugs item #847024, was opened at 2003-11-22 05:39
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=847024&group_id=5470
Category: Type/class unification
Group: Python 2.3
Status: Open
Resolution: None
Priority: 5
Submitted By: Michael Dubner (dubnerm)
Assigned to: Nobody/Anonymous (nobody)
Summary: NotImplemented return value misinterpreted in new classes
Initial Comment:
Following program:
------------------------------ notimpl.py
class CClassic:
def __add__(self, other):
return NotImplemented
def __mul__(self, other):
return NotImplemented
class CNew(object):
def __add__(self, other):
return NotImplemented
def __mul__(self, other):
return NotImplemented
a=CClassic()
try:
print a+2
except Exception, e:
print e
try:
print a*2
except Exception, e:
print e
a=CNew()
try:
print a+2
except Exception, e:
print e
try:
print a*2
except Exception, e:
print e
--------------------------------
Output following (correct) under Python 2.2:
unsupported operand types for +: 'instance' and 'int'
unsupported operand type(s) for *: 'instance' and 'int'
unsupported operand types for +: 'CNew' and 'int'
unsupported operand type(s) for *: 'CNew' and 'int'
And following (wrong) under Python 2.3[.2]:
unsupported operand type(s) for +: 'instance' and 'int'
unsupported operand type(s) for *: 'instance' and 'int'
unsupported operand type(s) for +: 'CNew' and 'int'
NotImplemented
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=847024&group_id=5470
More information about the Python-bugs-list
mailing list