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.

classification
Title: MutableSequence.__iadd__ should return self
Type: behavior Stage:
Components: Library (Lib) Versions: Python 3.0, Python 3.1, Python 2.7, Python 2.6
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: rhettinger Nosy List: amarzal, rhettinger
Priority: critical Keywords:

Created on 2009-05-16 09:45 by amarzal, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (4)
msg87872 - (view) Author: Andrés Marzal (amarzal) Date: 2009-05-16 09:45
I've implemented a LinkedList as a MutableSequence and __iadd__, which
is inherited from MutableSequence, does not perform as expected.
The _abcoll.py file contains this:

class MutableSequence(Sequence):
     ...
   def __iadd__(self, values):
       self.extend(values)

The method __iadd__ does not return anything, buy it should return
self. Right now, the sentence

aLinkedList += [1, 2]

sets the value of aLinkedList to None.
msg87873 - (view) Author: Andrés Marzal (amarzal) Date: 2009-05-16 09:46
I've implemented a LinkedList as a MutableSequence and __iadd__, which
is inherited from MutableSequence, does not perform as expected.
The _abcoll.py file contains this:

class MutableSequence(Sequence):
     ...
   def __iadd__(self, values):
       self.extend(values)

The method __iadd__ does not return anything, buy it should return
self. Right now, the sentence

aLinkedList += [1, 2]

sets the value of aLinkedList to None.
msg87956 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2009-05-17 03:18
I concur.  Will fix.
msg88031 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2009-05-18 15:56
Fixed in r72772 et al.  Thanks for the report
History
Date User Action Args
2022-04-11 14:56:48adminsetgithub: 50287
2009-05-18 15:56:15rhettingersetstatus: open -> closed
resolution: fixed
messages: + msg88031
2009-05-17 03:18:25rhettingersetpriority: critical

messages: + msg87956
versions: + Python 3.0, Python 3.1, Python 2.7
2009-05-16 13:04:00benjamin.petersonsetassignee: rhettinger

nosy: + rhettinger
2009-05-16 09:46:30amarzalsetmessages: + msg87873
2009-05-16 09:45:47amarzalcreate