diff --git a/stdlib/@tests/stubtest_allowlists/darwin.txt b/stdlib/@tests/stubtest_allowlists/darwin.txt index aeb4fd7ee..e5f736d8e 100644 --- a/stdlib/@tests/stubtest_allowlists/darwin.txt +++ b/stdlib/@tests/stubtest_allowlists/darwin.txt @@ -32,6 +32,8 @@ select.POLLMSG # system dependent _winapi asyncio.windows_events asyncio.windows_utils +encodings.oem +encodings.mbcs msvcrt nt winreg diff --git a/stdlib/@tests/stubtest_allowlists/linux.txt b/stdlib/@tests/stubtest_allowlists/linux.txt index ad8924a23..11b10f467 100644 --- a/stdlib/@tests/stubtest_allowlists/linux.txt +++ b/stdlib/@tests/stubtest_allowlists/linux.txt @@ -13,6 +13,8 @@ selectors.KqueueSelector _winapi asyncio.windows_events asyncio.windows_utils +encodings.oem +encodings.mbcs msvcrt nt winreg diff --git a/stdlib/@tests/stubtest_allowlists/win32.txt b/stdlib/@tests/stubtest_allowlists/win32.txt index 1fabe3bcb..f143fc9bc 100644 --- a/stdlib/@tests/stubtest_allowlists/win32.txt +++ b/stdlib/@tests/stubtest_allowlists/win32.txt @@ -4,8 +4,6 @@ ctypes.GetLastError # Is actually a pointer multiprocessing.reduction.AbstractReducer.DupHandle # Exists at runtime, but missing from stubs -encodings.mbcs -encodings.oem _winapi.CreateFileMapping _winapi.MapViewOfFile _winapi.OpenFileMapping diff --git a/stdlib/encodings/mbcs.pyi b/stdlib/encodings/mbcs.pyi new file mode 100644 index 000000000..2c2917d63 --- /dev/null +++ b/stdlib/encodings/mbcs.pyi @@ -0,0 +1,28 @@ +import codecs +import sys +from _typeshed import ReadableBuffer + +if sys.platform == "win32": + encode = codecs.mbcs_encode + + def decode(input: ReadableBuffer, errors: str | None = "strict") -> tuple[str, int]: ... + + class IncrementalEncoder(codecs.IncrementalEncoder): + def encode(self, input: str, final: bool = False) -> bytes: ... + + class IncrementalDecoder(codecs.BufferedIncrementalDecoder): + # At runtime, this is codecs.mbcs_decode + @staticmethod + def _buffer_decode(data: ReadableBuffer, errors: str | None = None, final: bool = False, /) -> tuple[str, int]: ... + + class StreamWriter(codecs.StreamWriter): + # At runtime, this is codecs.mbcs_encode + @staticmethod + def encode(str: str, errors: str | None = None, /) -> tuple[bytes, int]: ... + + class StreamReader(codecs.StreamReader): + # At runtime, this is codecs.mbcs_decode + @staticmethod + def decode(data: ReadableBuffer, errors: str | None = None, final: bool = False, /) -> tuple[str, int]: ... + + def getregentry() -> codecs.CodecInfo: ... diff --git a/stdlib/encodings/oem.pyi b/stdlib/encodings/oem.pyi new file mode 100644 index 000000000..376c12c44 --- /dev/null +++ b/stdlib/encodings/oem.pyi @@ -0,0 +1,28 @@ +import codecs +import sys +from _typeshed import ReadableBuffer + +if sys.platform == "win32": + encode = codecs.oem_encode + + def decode(input: ReadableBuffer, errors: str | None = "strict") -> tuple[str, int]: ... + + class IncrementalEncoder(codecs.IncrementalEncoder): + def encode(self, input: str, final: bool = False) -> bytes: ... + + class IncrementalDecoder(codecs.BufferedIncrementalDecoder): + # At runtime, this is codecs.oem_decode + @staticmethod + def _buffer_decode(data: ReadableBuffer, errors: str | None = None, final: bool = False, /) -> tuple[str, int]: ... + + class StreamWriter(codecs.StreamWriter): + # At runtime, this is codecs.oem_encode + @staticmethod + def encode(str: str, errors: str | None = None, /) -> tuple[bytes, int]: ... + + class StreamReader(codecs.StreamReader): + # At runtime, this is codecs.oem_decode + @staticmethod + def decode(data: ReadableBuffer, errors: str | None = None, final: bool = False, /) -> tuple[str, int]: ... + + def getregentry() -> codecs.CodecInfo: ...