From 4abe0b8c1b5df7031e568fc080de98ca6bc91474 Mon Sep 17 00:00:00 2001 From: Petr Ledvina Date: Mon, 6 Apr 2026 02:07:10 +0200 Subject: [PATCH] Fix `codecs.escape_decode` return type (#15531) Co-authored-by: Brian Schubert --- stdlib/_codecs.pyi | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/stdlib/_codecs.pyi b/stdlib/_codecs.pyi index 89f97edb9..89cb78c33 100644 --- a/stdlib/_codecs.pyi +++ b/stdlib/_codecs.pyi @@ -77,7 +77,9 @@ def ascii_decode(data: ReadableBuffer, errors: str | None = None, /) -> tuple[st def ascii_encode(str: str, errors: str | None = None, /) -> tuple[bytes, int]: ... def charmap_decode(data: ReadableBuffer, errors: str | None = None, mapping: _CharMap | None = None, /) -> tuple[str, int]: ... def charmap_encode(str: str, errors: str | None = None, mapping: _CharMap | None = None, /) -> tuple[bytes, int]: ... -def escape_decode(data: str | ReadableBuffer, errors: str | None = None, /) -> tuple[str, int]: ... + +# Docs say this accepts a bytes-like object, but in practice it also accepts str. +def escape_decode(data: str | ReadableBuffer, errors: str | None = None, /) -> tuple[bytes, int]: ... def escape_encode(data: bytes, errors: str | None = None, /) -> tuple[bytes, int]: ... def latin_1_decode(data: ReadableBuffer, errors: str | None = None, /) -> tuple[str, int]: ... def latin_1_encode(str: str, errors: str | None = None, /) -> tuple[bytes, int]: ...