Message147109
For example:
>>> (1, 2, 3).index(4)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: tuple.index(x): x not in tuple
The "x not in tuple" error message should be replaced with "4 is not in tuple". list.index() already does this (see #7252):
>>> [1, 2, 3].index(4)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: 4 is not in list
Although in #7252 it was claimed that no other place in stdlib has this error message, I found many occurences:
Modules/_collectionsmodule.c: PyErr_SetString(PyExc_ValueError, "deque.remove(x): x not in deque"
Modules/_elementtree.c: "list.remove(x): x not in list"
Modules/_elementtree.c: "list.remove(x): x not in list"
Modules/arraymodule.c: PyErr_SetString(PyExc_ValueError, "array.index(x): x not in list");
Modules/arraymodule.c: PyErr_SetString(PyExc_ValueError, "array.remove(x): x not in list");
Objects/abstract.c: "sequence.index(x): x not in sequence");
Objects/listobject.c: PyErr_SetString(PyExc_ValueError, "list.remove(x): x not in list");
Objects/tupleobject.c: PyErr_SetString(PyExc_ValueError, "tuple.index(x): x not in tuple");
There's also documentation and tests that depend on this actual error message:
Doc/library/doctest.rst: ValueError: list.remove(x): x not in list
Lib/test/test_xml_etree.py: ValueError: list.remove(x): x not in list
#7252 was fixed in r76058, and it's quite a lot of code. I think it could be done more easily using PyUnicode_FromFormat() and the %R format. |
|
Date |
User |
Action |
Args |
2011-11-05 20:49:38 | petri.lehtinen | set | recipients:
+ petri.lehtinen |
2011-11-05 20:49:37 | petri.lehtinen | set | messageid: <1320526177.89.0.678573577515.issue13349@psf.upfronthosting.co.za> |
2011-11-05 20:49:37 | petri.lehtinen | link | issue13349 messages |
2011-11-05 20:49:36 | petri.lehtinen | create | |
|