Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "gh-96844: Improve error message of list.remove (gh-106455)" #116956

Merged
merged 1 commit into from Mar 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions Doc/library/doctest.rst
Expand Up @@ -430,10 +430,10 @@ Simple example::
>>> [1, 2, 3].remove(42)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: 42 is not in list
ValueError: list.remove(x): x not in list

That doctest succeeds if :exc:`ValueError` is raised, with the ``42 is not in list``
detail as shown.
That doctest succeeds if :exc:`ValueError` is raised, with the ``list.remove(x):
x not in list`` detail as shown.

The expected output for an exception must start with a traceback header, which
may be either of the following two lines, indented the same as the first line of
Expand Down
2 changes: 1 addition & 1 deletion Lib/test/test_xml_etree.py
Expand Up @@ -329,7 +329,7 @@ def test_simpleops(self):
self.serialize_check(element, '<tag key="value" />') # 5
with self.assertRaises(ValueError) as cm:
element.remove(subelement)
self.assertIn('not in list', str(cm.exception))
self.assertEqual(str(cm.exception), 'list.remove(x): x not in list')
self.serialize_check(element, '<tag key="value" />') # 6
element[0:0] = [subelement, subelement, subelement]
self.serialize_check(element[1], '<subtag />')
Expand Down
2 changes: 1 addition & 1 deletion Objects/listobject.c
Expand Up @@ -3194,7 +3194,7 @@ list_remove_impl(PyListObject *self, PyObject *value)
else if (cmp < 0)
return NULL;
}
PyErr_Format(PyExc_ValueError, "%R is not in list", value);
PyErr_SetString(PyExc_ValueError, "list.remove(x): x not in list");
return NULL;
}

Expand Down