FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Allow keyword errors for UTF-8 decoders by jw9829 · Pull Request #16447 · python/typeshed · GitHub

Repository navigation

Allow keyword errors for UTF-8 decoders - #16447

Open
jw9829 wants to merge 4 commits into
python:mainfrom
jw9829:fix-codecs-decoder-keyword-errors-repost
Open

jw9829 wants to merge 4 commits into
python:mainfrom
jw9829:fix-codecs-decoder-keyword-errors-repost

Conversation

jw9829 commented Sep 27, 2026 •
edited
Loading

Copy link
Copy Markdown

Fixes #16441.

The UTF-8 decoder returned by codecs.lookup() accepts errors= as a keyword. Other codecs keep a positional-only signature because some reject keyword arguments.

This comment has been minimized.

Comment thread stdlib/codecs.pyi Outdated
@type_check_only
class _Decoder(Protocol):
def __call__(self, input: ReadableBuffer, errors: str = ..., /) -> tuple[str, int]: ... # signature of Codec().decode
def __call__(self, input: ReadableBuffer, /, errors: str = ...) -> tuple[str, int]: ... # signature of Codec().decode

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

This is not correct for all codecs:

>>> codecs.lookup("ascii").decode(b"abc", errors="replace")
Traceback (most recent call last):
  File "<python-input-3>", line 1, in <module>
    codecs.lookup("ascii").decode(b"abc", errors="replace")
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: _codecs.ascii_decode() takes no keyword arguments

jw9829 changed the title Allow keyword errors for codec decoders Allow keyword errors for UTF-8 decoders Sep 27, 2026

Copy link
Copy Markdown
Contributor

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

Comment thread stdlib/codecs.pyi

This branch has not been deployed

No deployments
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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.

false alarm on decode call

2 participants


Back | FazBrowse Home | New Git URL