mirror of
https://github.com/python/cpython.git
synced 2025-12-04 00:30:19 +00:00
Add bytes/bytearray.maketrans() to mirror str.maketrans(), and deprecate
string.maketrans() which actually works on bytes. (Also closes #5675.)
This commit is contained in:
parent
78532baeab
commit
abc387747d
11 changed files with 134 additions and 32 deletions
|
|
@ -49,6 +49,9 @@ def maketrans(frm: bytes, to: bytes) -> bytes:
|
|||
mapped to the byte at the same position in to.
|
||||
The strings frm and to must be of the same length.
|
||||
"""
|
||||
import warnings
|
||||
warnings.warn("string.maketrans is deprecated, use bytes.maketrans instead",
|
||||
DeprecationWarning)
|
||||
if len(frm) != len(to):
|
||||
raise ValueError("maketrans arguments must have same length")
|
||||
if not (isinstance(frm, bytes) and isinstance(to, bytes)):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue