[issue15773] `is' operator returns False on classmethods

2012-08-23 Thread Nick Coghlan

Nick Coghlan added the comment:

Bound methods are created dynamically on lookup, while object ids may be reused 
after the original object is destroyed.

There's no bug here - just a combination of those two language behaviours that 
is frequently surprising to users that have just noticed it.

There's not a lot we can do about that - it's a genuinely surprising moment in 
people's understanding of the way methods (and descriptors in general) work.

--
nosy: +ncoghlan
resolution:  -> invalid
stage:  -> committed/rejected
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue15773] `is' operator returns False on classmethods

2012-08-23 Thread Stefan Mihaila

Changes by Stefan Mihaila :


--
type:  -> behavior

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue15773] `is' operator returns False on classmethods

2012-08-23 Thread Stefan Mihaila

New submission from Stefan Mihaila:

Here are a few counter-intuitive outputs:

>>> dict.fromkeys is dict.fromkeys
False

>>> id(dict.fromkeys) == id(dict.fromkeys)
True

>>> x=dict.fromkeys; id(x) == id(x)
True

>>> x=dict.fromkeys; id(x) == id(dict.fromkeys)
False

>>> x=dict.fromkeys; y=dict.fromkeys; id(x),id(y),id(dict.fromkeys)
(3924, 39064632, 39065144)

>>> a=id(dict.fromkeys); x=dict.fromkeys; b=id(dict.fromkeys); a,b
(3924, 39480568)

Attached is a failing test.

--
files: is_on_classmethods.py
messages: 168967
nosy: mstefanro
priority: normal
severity: normal
status: open
title: `is' operator returns False on classmethods
versions: Python 3.3
Added file: http://bugs.python.org/file26978/is_on_classmethods.py

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com