Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

gh-96844: Improve error message of list.remove#106455

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
corona10 merged 3 commits intopython:mainfromcorona10:gh-96844
Jul 5, 2023
Merged
Show file tree
Hide file tree
Changes from1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
NextNext commit
gh-96844: Improve error message of list.remove
  • Loading branch information
@corona10
corona10 committedJul 5, 2023
commit1bfde406e750b95938c5d856a3379436980f996a
6 changes: 3 additions & 3 deletionsDoc/library/doctest.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -409,10 +409,10 @@ Simple example::
>>> [1, 2, 3].remove(42)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError:list.remove(x): x not in list
ValueError:42 is not in list

That doctest succeeds if :exc:`ValueError` is raised, with the ``list.remove(x):
x not in list`` detail as shown.
That doctest succeeds if :exc:`ValueError` is raised, with the ``42 is not inlist
`` 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
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
Improve error message of :meth:`list.remove`. Patch by Dong-hee Na.
2 changes: 1 addition & 1 deletionObjects/listobject.c
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -2694,7 +2694,7 @@ list_remove(PyListObject *self, PyObject *value)
else if (cmp < 0)
return NULL;
}
PyErr_SetString(PyExc_ValueError, "list.remove(x): x not in list");
PyErr_Format(PyExc_ValueError, "%R is not in list", value);
return NULL;
}

Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp