Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NotImplemented return value misinterpreted in new classes #39584

Closed
dubnerm mannequin opened this issue Nov 22, 2003 · 3 comments
Closed

NotImplemented return value misinterpreted in new classes #39584

dubnerm mannequin opened this issue Nov 22, 2003 · 3 comments
Assignees
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs)

Comments

@dubnerm
Copy link
Mannequin

dubnerm mannequin commented Nov 22, 2003

BPO 847024
Nosy @mwhudson, @birkenfeld, @birkenfeld

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = 'https://github.com/mwhudson'
closed_at = <Date 2006-02-20.19:53:50.000>
created_at = <Date 2003-11-22.02:39:43.000>
labels = ['interpreter-core']
title = 'NotImplemented return value misinterpreted in new classes'
updated_at = <Date 2006-02-20.19:53:50.000>
user = 'https://bugs.python.org/dubnerm'

bugs.python.org fields:

activity = <Date 2006-02-20.19:53:50.000>
actor = 'georg.brandl'
assignee = 'mwh'
closed = True
closed_date = None
closer = None
components = ['Interpreter Core']
creation = <Date 2003-11-22.02:39:43.000>
creator = 'dubnerm'
dependencies = []
files = []
hgrepos = []
issue_num = 847024
keywords = []
message_count = 3.0
messages = ['19086', '19087', '19088']
nosy_count = 4.0
nosy_names = ['mwh', 'georg.brandl', 'georg.brandl', 'dubnerm']
pr_nums = []
priority = 'normal'
resolution = 'fixed'
stage = None
status = 'closed'
superseder = None
type = None
url = 'https://bugs.python.org/issue847024'
versions = ['Python 2.3']

@dubnerm
Copy link
Mannequin Author

dubnerm mannequin commented Nov 22, 2003

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

@dubnerm dubnerm mannequin closed this as completed Nov 22, 2003
@dubnerm dubnerm mannequin assigned mwhudson Nov 22, 2003
@dubnerm dubnerm mannequin added the interpreter-core (Objects, Python, Grammar, and Parser dirs) label Nov 22, 2003
@dubnerm dubnerm mannequin closed this as completed Nov 22, 2003
@dubnerm dubnerm mannequin assigned mwhudson Nov 22, 2003
@dubnerm dubnerm mannequin added the interpreter-core (Objects, Python, Grammar, and Parser dirs) label Nov 22, 2003
@birkenfeld
Copy link
Member

Logged In: YES
user_id=1188172

I could reproduce with all my Pythons. I looked around a bit
but couldn't find any cause of this. Michael, do you have
more luck?

@birkenfeld
Copy link
Member

Logged In: YES
user_id=849994

This now seems to be fixed in 2.5 HEAD and 2.4 branch. Cheers!

@ezio-melotti ezio-melotti transferred this issue from another repository Apr 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs)
Projects
None yet
Development

No branches or pull requests

2 participants