Skip to content

Update str.translate() docstring to match docs #136897

@hyperkai

Description

@hyperkai

Bug report

Bug description:

str.translate() by help() says it must be a string as shown below:

print(help("".translate))

table
   Translation table, which must be a mapping of Unicode ordinals to
   Unicode ordinals, strings, or None.

But the byte strings with bytes.maketrans() and bytearray.maketrans() also work with str.translate() as shown below:

table1 = bytes.maketrans(b"abc", b"xyz")
table2 = bytearray.maketrans(b"abc", b"xyz")

print("AaBbCc".translate(table1))
print("AaBbCc".translate(table2))
# AxByCz

CPython versions tested on:

3.12

Operating systems tested on:

Windows

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    docsDocumentation in the Doc direasyinterpreter-core(Objects, Python, Grammar, and Parser dirs)

    Projects

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions