Skip to content

Commit 627a3aa

Browse files
Update docstring of str.translate
1 parent 89c220b commit 627a3aa

2 files changed

Lines changed: 12 additions & 10 deletions

File tree

Objects/clinic/unicodeobject.c.h

Lines changed: 6 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Objects/unicodeobject.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13477,20 +13477,21 @@ unicode_maketrans_impl(PyObject *x, PyObject *y, PyObject *z)
1347713477
str.translate as unicode_translate
1347813478
1347913479
table: object
13480-
Translation table, which must be a mapping of Unicode ordinals to
13481-
Unicode ordinals, strings, or None.
13480+
Translation table, which must be an object that implements indexing via __getitem__(),
13481+
typically a mapping or sequence.
1348213482
/
1348313483
1348413484
Replace each character in the string using the given translation table.
1348513485
1348613486
The table must implement lookup/indexing via __getitem__, for instance a
13487-
dictionary or list. If this operation raises LookupError, the character is
13488-
left untouched. Characters mapped to None are deleted.
13487+
dictionary or list. When indexed by a Unicode ordinal, it may return another
13488+
Unicode ordinal or a string to replace the character, return None to delete
13489+
it, or raise LookupError to leave it unchanged.
1348913490
[clinic start generated code]*/
1349013491

1349113492
static PyObject *
1349213493
unicode_translate(PyObject *self, PyObject *table)
13493-
/*[clinic end generated code: output=3cb448ff2fd96bf3 input=6d38343db63d8eb0]*/
13494+
/*[clinic end generated code: output=3cb448ff2fd96bf3 input=6bb9205d97271b8b]*/
1349413495
{
1349513496
return _PyUnicode_TranslateCharmap(self, table, "ignore");
1349613497
}

0 commit comments

Comments
 (0)