[Python-bugs-list] [ python-Bugs-452252 ] __iadd__ sets object to None
noreply@sourceforge.net
noreply@sourceforge.net
Fri, 17 Aug 2001 15:46:51 -0700
Bugs item #452252, was opened at 2001-08-17 15:46
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=452252&group_id=5470
Category: Python Interpreter Core
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: John Shipman (shipman)
Assigned to: Nobody/Anonymous (nobody)
Summary: __iadd__ sets object to None
Initial Comment:
Here's my version info:
ActivePython 2.1, build 211 (ActiveState)
based on Python 2.1 (#1, Jun 15 2001, 02:52:41)
[GCC 2.95.2 20000220 (Debian GNU/Linux)] on linux2
If I overload `+=' in a class using an __iadd__
method, the object is replaced by None. Here's
a script that demonstrates the problem:
=====================================================
#!/usr/local/bin/python
#--
# iadd: See if __iadd__ actually works
#--
class C:
def __init__ ( self, value ):
self.value = value
def __str__ ( self ):
return "C<%s>" % self.value
def __repr__ ( self ):
return str(self)
def __iadd__ ( self, x ):
self.value = self.value + x
# - - - - - m a i n - - - - -
c = C(37)
print "Before:", c
c += 10
print "Add 10:", c
=====================================================
And here's the output I get:
=====================================================
Before: C<37>
Add 10: None
=====================================================
----------------------------------------------------------------------
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=452252&group_id=5470