New submission from Dominik Schmid:

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

----------
components: Interpreter Core
files: bug.py
messages: 255853
nosy: Dominik Schmid
priority: normal
severity: normal
status: open
title: __setattr__ does not always overload operators
type: behavior
versions: Python 2.7
Added file: http://bugs.python.org/file41234/bug.py

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue25794>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to