From 05955c0cb8d487023ef4c308dc42cfe68c7629d5 Mon Sep 17 00:00:00 2001 From: Amin Alaee Date: Mon, 27 May 2024 14:12:00 +0200 Subject: [PATCH] `json`, `ipaddress`, `locale`: Python3.13 updates (#12046) Co-authored-by: Alex Waygood --- stdlib/@tests/stubtest_allowlists/py313.txt | 4 ---- stdlib/ipaddress.pyi | 6 +++++- stdlib/json/encoder.pyi | 4 ++-- stdlib/locale.pyi | 8 ++++++-- 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/stdlib/@tests/stubtest_allowlists/py313.txt b/stdlib/@tests/stubtest_allowlists/py313.txt index 5a48838c7..e8ed597ad 100644 --- a/stdlib/@tests/stubtest_allowlists/py313.txt +++ b/stdlib/@tests/stubtest_allowlists/py313.txt @@ -120,10 +120,6 @@ importlib.resources.path importlib.resources.read_binary importlib.resources.read_text io.IOBase._checkClosed -ipaddress.IPv4Address.ipv6_mapped -json.encoder.encode_basestring -json.encoder.encode_basestring_ascii -locale.resetlocale mailbox.Maildir.add_flag mailbox.Maildir.get_flags mailbox.Maildir.get_info diff --git a/stdlib/ipaddress.pyi b/stdlib/ipaddress.pyi index 98b1893d2..03decc74e 100644 --- a/stdlib/ipaddress.pyi +++ b/stdlib/ipaddress.pyi @@ -147,7 +147,11 @@ class _BaseV4: @property def max_prefixlen(self) -> Literal[32]: ... -class IPv4Address(_BaseV4, _BaseAddress): ... +class IPv4Address(_BaseV4, _BaseAddress): + if sys.version_info >= (3, 13): + @property + def ipv6_mapped(self) -> IPv6Address: ... + class IPv4Network(_BaseV4, _BaseNetwork[IPv4Address]): ... class IPv4Interface(IPv4Address, _BaseInterface[IPv4Address, IPv4Network]): diff --git a/stdlib/json/encoder.pyi b/stdlib/json/encoder.pyi index c1062688b..473398a60 100644 --- a/stdlib/json/encoder.pyi +++ b/stdlib/json/encoder.pyi @@ -10,8 +10,8 @@ INFINITY: float def py_encode_basestring(s: str) -> str: ... # undocumented def py_encode_basestring_ascii(s: str) -> str: ... # undocumented -def encode_basestring(s: str) -> str: ... # undocumented -def encode_basestring_ascii(s: str) -> str: ... # undocumented +def encode_basestring(s: str, /) -> str: ... # undocumented +def encode_basestring_ascii(s: str, /) -> str: ... # undocumented class JSONEncoder: item_separator: str diff --git a/stdlib/locale.pyi b/stdlib/locale.pyi index c18523e04..58de65449 100644 --- a/stdlib/locale.pyi +++ b/stdlib/locale.pyi @@ -96,7 +96,6 @@ __all__ = [ "getpreferredencoding", "Error", "setlocale", - "resetlocale", "localeconv", "strcoll", "strxfrm", @@ -121,6 +120,9 @@ if sys.version_info >= (3, 11): if sys.version_info < (3, 12): __all__ += ["format"] +if sys.version_info < (3, 13): + __all__ += ["resetlocale"] + if sys.platform != "win32": __all__ += ["LC_MESSAGES"] @@ -133,7 +135,9 @@ def getlocale(category: int = ...) -> tuple[_str | None, _str | None]: ... def setlocale(category: int, locale: _str | Iterable[_str | None] | None = None) -> _str: ... def getpreferredencoding(do_setlocale: bool = True) -> _str: ... def normalize(localename: _str) -> _str: ... -def resetlocale(category: int = ...) -> None: ... + +if sys.version_info < (3, 13): + def resetlocale(category: int = ...) -> None: ... if sys.version_info < (3, 12): def format(