From ac3d422330df826d057ef32722f3ff8179b2a2cc Mon Sep 17 00:00:00 2001 From: Max Muoto Date: Mon, 15 Jul 2024 07:03:33 -0500 Subject: [PATCH] Enforce positional args for `codec` functions (#12343) --- stdlib/@tests/stubtest_allowlists/py313.txt | 14 ++++++++------ stdlib/codecs.pyi | 12 ++++++------ 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/stdlib/@tests/stubtest_allowlists/py313.txt b/stdlib/@tests/stubtest_allowlists/py313.txt index 5f62a8b7e..268b03053 100644 --- a/stdlib/@tests/stubtest_allowlists/py313.txt +++ b/stdlib/@tests/stubtest_allowlists/py313.txt @@ -7,12 +7,6 @@ _thread.interrupt_main _thread.lock _thread.start_joinable_thread _tkinter.create -codecs.backslashreplace_errors -codecs.ignore_errors -codecs.namereplace_errors -codecs.replace_errors -codecs.strict_errors -codecs.xmlcharrefreplace_errors ctypes._endian.DEFAULT_MODE ctypes._endian.RTLD_GLOBAL ctypes._endian.RTLD_LOCAL @@ -202,3 +196,11 @@ typing.SupportsAbs.__type_params__ typing.SupportsRound.__type_params__ typing_extensions.SupportsAbs.__type_params__ typing_extensions.SupportsRound.__type_params__ + +# Runtime incorrectly has `self` +codecs.backslashreplace_errors +codecs.ignore_errors +codecs.namereplace_errors +codecs.replace_errors +codecs.strict_errors +codecs.xmlcharrefreplace_errors diff --git a/stdlib/codecs.pyi b/stdlib/codecs.pyi index 6e53b780c..fb4edf010 100644 --- a/stdlib/codecs.pyi +++ b/stdlib/codecs.pyi @@ -146,12 +146,12 @@ BOM_UTF32: Literal[b"\xff\xfe\x00\x00", b"\x00\x00\xfe\xff"] # depends on `sys. BOM_UTF32_BE: Literal[b"\x00\x00\xfe\xff"] BOM_UTF32_LE: Literal[b"\xff\xfe\x00\x00"] -def strict_errors(exception: UnicodeError) -> tuple[str | bytes, int]: ... -def replace_errors(exception: UnicodeError) -> tuple[str | bytes, int]: ... -def ignore_errors(exception: UnicodeError) -> tuple[str | bytes, int]: ... -def xmlcharrefreplace_errors(exception: UnicodeError) -> tuple[str | bytes, int]: ... -def backslashreplace_errors(exception: UnicodeError) -> tuple[str | bytes, int]: ... -def namereplace_errors(exception: UnicodeError) -> tuple[str | bytes, int]: ... +def strict_errors(exception: UnicodeError, /) -> tuple[str | bytes, int]: ... +def replace_errors(exception: UnicodeError, /) -> tuple[str | bytes, int]: ... +def ignore_errors(exception: UnicodeError, /) -> tuple[str | bytes, int]: ... +def xmlcharrefreplace_errors(exception: UnicodeError, /) -> tuple[str | bytes, int]: ... +def backslashreplace_errors(exception: UnicodeError, /) -> tuple[str | bytes, int]: ... +def namereplace_errors(exception: UnicodeError, /) -> tuple[str | bytes, int]: ... class Codec: # These are sort of @abstractmethod but sort of not.