From a531872b00e0c3697603c9824942b0e8f6628d40 Mon Sep 17 00:00:00 2001 From: Steven Troxler Date: Tue, 13 Oct 2026 09:12:22 -0700 Subject: [PATCH] Fix codecs.register_error callback type The callback receives one of the three concrete Unicode codec error types. Model that union so contextual typing exposes their shared attributes. --- stdlib/_codecs.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stdlib/_codecs.pyi b/stdlib/_codecs.pyi index 449e9e24af9b..e854c80ff375 100644 --- a/stdlib/_codecs.pyi +++ b/stdlib/_codecs.pyi @@ -13,7 +13,7 @@ class _EncodingMap: _DecodeCharMap: TypeAlias = SupportsGetItem[int, str | int | None] _EncodeCharMap: TypeAlias = SupportsGetItem[int, bytes | int | None] | _EncodingMap -_Handler: TypeAlias = Callable[[UnicodeError], tuple[str | bytes, int]] +_Handler: TypeAlias = Callable[[UnicodeEncodeError | UnicodeDecodeError | UnicodeTranslateError], tuple[str | bytes, int]] _SearchFunction: TypeAlias = Callable[[str], codecs.CodecInfo | None] def register(search_function: _SearchFunction, /) -> None: ...