Issue 847024: NotImplemented return value misinterpreted in new classes (original) (raw)
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 a2 except Exception, e: print e a=CNew() try: print a+2 except Exception, e: print e try: print a2 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