Skip to content

Commit 37e9746

Browse files
authored
Fix codecs.register_error callback type (#16518)
The callback receives one of the three concrete Unicode codec error types. Model that union so contextual typing exposes their shared attributes.
1 parent 4bca622 commit 37e9746

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

‎stdlib/_codecs.pyi‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class _EncodingMap:
1313

1414
_DecodeCharMap: TypeAlias = SupportsGetItem[int, str | int | None]
1515
_EncodeCharMap: TypeAlias = SupportsGetItem[int, bytes | int | None] | _EncodingMap
16-
_Handler: TypeAlias = Callable[[UnicodeError], tuple[str | bytes, int]]
16+
_Handler: TypeAlias = Callable[[UnicodeEncodeError | UnicodeDecodeError | UnicodeTranslateError], tuple[str | bytes, int]]
1717
_SearchFunction: TypeAlias = Callable[[str], codecs.CodecInfo | None]
1818

1919
def register(search_function: _SearchFunction, /) -> None: ...

0 commit comments

Comments
 (0)