Skip to content

Comments

bytes.translate: generalize delete parameter type#14372

Merged
hauntsaninja merged 1 commit intopython:mainfrom
sharkdp:bytes-translate-delete
Jul 7, 2025
Merged

bytes.translate: generalize delete parameter type#14372
hauntsaninja merged 1 commit intopython:mainfrom
sharkdp:bytes-translate-delete

Conversation

@sharkdp
Copy link
Contributor

@sharkdp sharkdp commented Jul 7, 2025

The delete parameter of the bytes.translate function accepts all readable buffers, not just bytes objects:

>>> b"abc".translate(None, bytearray(b"b"))
b'ac'
>>> b"abc".translate(None, memoryview(b"b"))
b'ac'

If the delete argument is not a bytes subclass, the CPython implementation calls PyObject_GetBuffer here.

@github-actions
Copy link
Contributor

github-actions bot commented Jul 7, 2025

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

Copy link
Collaborator

@hauntsaninja hauntsaninja left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@hauntsaninja hauntsaninja merged commit f647075 into python:main Jul 7, 2025
64 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants