Skip to content

[encodings] Accept buffer inputs in Codec.decode for cp1250-cp1258 - #16686

Open
huuan26 wants to merge 1 commit into
python:mainfrom
huuan26:fix/encodings-cp125x-decode-buffer
Open

huuan26 wants to merge 1 commit into
python:mainfrom
huuan26:fix/encodings-cp125x-decode-buffer

Conversation

@huuan26

@huuan26 huuan26 commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

Accept buffer inputs in \Codec.decode\ across \stdlib/encodings/cp1250.pyi\ through \cp1258.pyi, matching their runtime CPython implementation as well as \cp1252.pyi\ (updated in #16665).

In Python, standard library codec \decode\ methods accept any object implementing the buffer protocol (\ReadableBuffer\ like \�ytes, \�ytearray, \memoryview).

@github-actions

github-actions Bot commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

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

@srittau

srittau commented Nov 4, 2026

Copy link
Copy Markdown
Collaborator

Do you have a link to the implementation in CPython to verify this?

@huuan26

huuan26 commented Nov 5, 2026

Copy link
Copy Markdown
Contributor Author

Here are the links to the CPython implementation:

  1. Lib/encodings/cp1250.py – cp1258.py (generated via Tools/unicode/gencodec.py):
    Codec.decode delegates directly to codecs.charmap_decode(input, errors, decoding_table) (just like IncrementalDecoder.decode, which is already typed with ReadableBuffer in these stubs):

  2. Modules/_codecsmodule.c (_codecs.charmap_decode):
    In Argument Clinic, charmap_decode takes data: Py_buffer, accepting any ReadableBuffer (�ytes, �ytearray, memoryview, etc.), which matches _codecs.charmap_decode(data: ReadableBuffer, ...) in stdlib/_codecs.pyi:

This branch has not been deployed

No deployments
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