Issue 739313: array.insert and negative indices (original) (raw)

Created on 2003-05-18 01:29 by doerwalter, last changed 2022-04-10 16:08 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
patch.txt tim.peters,2003-05-18 01:48 Fix array.insert for negative index
Messages (5)
msg16044 - (view) Author: Walter Dörwald (doerwalter) * (Python committer) Date: 2003-05-18 01:29
2.3b1 changed list.insert() so that negative indices are treated as being relative to the end of the list, but array.array.insert() still treats all negative indices as 0: >>> import array >>> a = array.array("c", "spam") >>> a.insert(-1, "x") >>> a array('c', 'xspam')
msg16045 - (view) Author: Tim Peters (tim.peters) * (Python committer) Date: 2003-05-18 01:48
Logged In: YES user_id=31435 Good point! I've attached the right patch. If someone else can make time to write a test/docs/NEWS, I'd appreciate it.
msg16046 - (view) Author: Walter Dörwald (doerwalter) * (Python committer) Date: 2003-05-18 02:00
Logged In: YES user_id=89016 OK, I'll add tests/docs/NEWS
msg16047 - (view) Author: Walter Dörwald (doerwalter) * (Python committer) Date: 2003-05-18 03:17
Logged In: YES user_id=89016 Checked in as: Lib/test/test_array.py 1.22 Doc/lib/libarray.tex 1.36 Misc/NEWS 1.769 Modules/arraymodule.c 2.89 Should the docstring be updated too? It seems to be rather terse.
msg16048 - (view) Author: Tim Peters (tim.peters) * (Python committer) Date: 2003-05-18 04:27
Logged In: YES user_id=31435 Well, Guido would probably shrink the docstring, by taking the information-free "a new item" out of it. That would make it closer to the list.insert() docstring, BTW. The unenforced rule is that docstrings are mnemonic, and the real docs are in the manuals. I think it says enough as-is.
History
Date User Action Args
2022-04-10 16:08:49 admin set github: 38518
2003-05-18 01:29:08 doerwalter create