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 serhiy.storchaka
Recipients mark.dickinson, python-dev, rhettinger, serhiy.storchaka, tim.peters
Date 2016-01-27.06:59:13
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1453877954.19.0.836103527316.issue26194@psf.upfronthosting.co.za>
In-reply-to
Content
New behavior looks less surprising to me.

Old behavior is even more weird for negative indices:

>>> from collections import deque
>>> d = deque(range(20), maxlen=10)
>>> d
deque([10, 11, 12, 13, 14, 15, 16, 17, 18, 19], maxlen=10)
>>> d.insert(-3, 'New')
>>> d
deque([11, 12, 13, 14, 15, 16, 'New', 18, 19, 10], maxlen=10)

Note that new element not just replaced the old one in the middle of the deque, but all context was rotated one position left.

Patched code behave less surprising.

>>> d.insert(-3, 'New')
>>> d                                                                   
deque([10, 11, 12, 13, 14, 15, 'New', 16, 17, 18], maxlen=10)
History
Date User Action Args
2016-01-27 06:59:14serhiy.storchakasetrecipients: + serhiy.storchaka, tim.peters, rhettinger, mark.dickinson, python-dev
2016-01-27 06:59:14serhiy.storchakasetmessageid: <1453877954.19.0.836103527316.issue26194@psf.upfronthosting.co.za>
2016-01-27 06:59:14serhiy.storchakalinkissue26194 messages
2016-01-27 06:59:13serhiy.storchakacreate