Skip to content

gh-136897: Update docstring of str.translate #136954

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
11 changes: 6 additions & 5 deletions Objects/clinic/unicodeobject.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 6 additions & 5 deletions Objects/unicodeobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -13477,20 +13477,21 @@ unicode_maketrans_impl(PyObject *x, PyObject *y, PyObject *z)
str.translate as unicode_translate

table: object
Translation table, which must be a mapping of Unicode ordinals to
Unicode ordinals, strings, or None.
Translation table, which must be an object that implements indexing via __getitem__(),
typically a mapping or sequence.
/

Replace each character in the string using the given translation table.

The table must implement lookup/indexing via __getitem__, for instance a
dictionary or list. If this operation raises LookupError, the character is
left untouched. Characters mapped to None are deleted.
dictionary or list. When indexed by a Unicode ordinal, it may return another
Unicode ordinal or a string to replace the character, return None to delete
it, or raise LookupError to leave it unchanged.
[clinic start generated code]*/

static PyObject *
unicode_translate(PyObject *self, PyObject *table)
/*[clinic end generated code: output=3cb448ff2fd96bf3 input=6d38343db63d8eb0]*/
/*[clinic end generated code: output=3cb448ff2fd96bf3 input=6bb9205d97271b8b]*/
{
return _PyUnicode_TranslateCharmap(self, table, "ignore");
}
Expand Down
Loading