Add encodings.mbcs and encodings.oem (#13122)

This commit is contained in:
Stephen Morton
2024-11-26 20:02:49 -08:00
committed by GitHub
parent 720946c9d2
commit 900e5c5b1b
5 changed files with 60 additions and 2 deletions

View File

@@ -32,6 +32,8 @@ select.POLLMSG # system dependent
_winapi
asyncio.windows_events
asyncio.windows_utils
encodings.oem
encodings.mbcs
msvcrt
nt
winreg

View File

@@ -13,6 +13,8 @@ selectors.KqueueSelector
_winapi
asyncio.windows_events
asyncio.windows_utils
encodings.oem
encodings.mbcs
msvcrt
nt
winreg

View File

@@ -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

28
stdlib/encodings/mbcs.pyi Normal file
View File

@@ -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: ...

28
stdlib/encodings/oem.pyi Normal file
View File

@@ -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: ...