This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Dominik Schmid
Recipients Dominik Schmid
Date 2015-12-04.08:52:35
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1449219157.0.0.30103039285.issue25794@psf.upfronthosting.co.za>
In-reply-to
Content
While implementing my own Integer class that keeps track of when operations are applied I noticed that setattr had a strange behaviour when I tried to wrap operator functions.

When the attribute string had a different id to its literal it failed to overload the operator.
Are we doing a 'is' rather than a '==' somewhere in setattr?


expected result: 
139723705431168    a.__add__(b)= (5)    a+b= (5)
139723705431168    a.__add__(b)= (5)    a+b= (5)
139723704361584    a.__add__(b)= (5)    a+b= (5)


actual result:
139723705431168    a.__add__(b)= (5)    a+b= (5)
139723705431168    a.__add__(b)= (5)    a+b= (5)
139723704361584    a.__add__(b)= (5)    a+b=
Traceback (most recent call last):
  File "/home/dom/Documents/leastOps/bug.py", line 41, in <module>
    testSetattr(funcName3)
  File "/home/dom/Documents/leastOps/bug.py", line 28, in testSetattr
    print '   a+b=', a+b
TypeError: unsupported operand type(s) for +: 'Integer' and 'Integer'



version:
2.7.10 (default, Oct 14 2015, 16:09:02) 
[GCC 5.2.1 20151010]
ubuntu 14.10
History
Date User Action Args
2015-12-04 08:52:37Dominik Schmidsetrecipients: + Dominik Schmid
2015-12-04 08:52:37Dominik Schmidsetmessageid: <1449219157.0.0.30103039285.issue25794@psf.upfronthosting.co.za>
2015-12-04 08:52:36Dominik Schmidlinkissue25794 messages
2015-12-04 08:52:36Dominik Schmidcreate