Skip to content

bytearray.maketrans() returns a bytes type value instead of a bytearray type value #137234

@hyperkai

Description

@hyperkai

Bug report

Bug description:

bytearray.maketrans() returns a bytes type value instead of a bytearray type value as shown below:

table = bytearray.maketrans(b'abc', b'xyz')
table = bytearray.maketrans(bytearray(b'abc'), bytearray(b'xyz'))

print(type(table)) # <class 'bytes'>

So, bytearray.maketrans() should return a bytearray type value like below:

table = bytearray.maketrans(b'abc', b'xyz')
table = bytearray.maketrans(bytearray(b'abc'), bytearray(b'xyz'))

print(type(table)) # <class 'bytearray'>

In addition, bytes.maketrans() returns a bytes type value properly as shown below:

table = bytes.maketrans(b'abc', b'xyz')
table = bytes.maketrans(bytearray(b'abc'), bytearray(b'xyz'))

print(type(table)) # <class 'bytes'>

CPython versions tested on:

3.12

Operating systems tested on:

Windows

Metadata

Metadata

Assignees

No one assigned

    Labels

    type-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions