From b45456739a5f6b2bcf0201c4bcf945c8d6c580ab Mon Sep 17 00:00:00 2001 From: Amin Alaee Date: Wed, 29 May 2024 14:37:26 +0200 Subject: [PATCH] `platform`, `tarfile`, `io`: Python 3.13 updates (#12056) --- stdlib/@tests/stubtest_allowlists/py313.txt | 6 --- stdlib/io.pyi | 2 +- stdlib/platform.pyi | 25 ++++++++++ stdlib/tarfile.pyi | 53 ++++++++++++++------- 4 files changed, 63 insertions(+), 23 deletions(-) diff --git a/stdlib/@tests/stubtest_allowlists/py313.txt b/stdlib/@tests/stubtest_allowlists/py313.txt index 4729ae764..34431c3d1 100644 --- a/stdlib/@tests/stubtest_allowlists/py313.txt +++ b/stdlib/@tests/stubtest_allowlists/py313.txt @@ -119,7 +119,6 @@ importlib.resources.open_text importlib.resources.path importlib.resources.read_binary importlib.resources.read_text -io.IOBase._checkClosed mailbox.Maildir.add_flag mailbox.Maildir.get_flags mailbox.Maildir.get_info @@ -139,10 +138,6 @@ pdb.Pdb.do_exceptions pdb.Pdb.interaction pdb.Pdb.message pdb.Pdb.user_opcode -platform.AndroidVer -platform.IOSVersionInfo -platform.android_ver -platform.ios_ver pstats.FunctionProfile.__replace__ pstats.StatsProfile.__replace__ pydoc.pager @@ -157,7 +152,6 @@ sqlite3.dbapi2.Connection.iterdump sre_compile.SRE_FLAG_TEMPLATE sre_constants.SRE_FLAG_TEMPLATE sre_parse.SRE_FLAG_TEMPLATE -tarfile.TarFile.__init__ threading.stack_size tkinter.Misc.after_info tkinter.Misc.busy diff --git a/stdlib/io.pyi b/stdlib/io.pyi index fdbbc8ddd..01f3bfc06 100644 --- a/stdlib/io.pyi +++ b/stdlib/io.pyi @@ -75,7 +75,7 @@ class IOBase(metaclass=abc.ABCMeta): def __del__(self) -> None: ... @property def closed(self) -> bool: ... - def _checkClosed(self, msg: str | None = ...) -> None: ... # undocumented + def _checkClosed(self) -> None: ... # undocumented class RawIOBase(IOBase): def readall(self) -> bytes: ... diff --git a/stdlib/platform.pyi b/stdlib/platform.pyi index f0e6d4123..c47ecdc51 100644 --- a/stdlib/platform.pyi +++ b/stdlib/platform.pyi @@ -40,3 +40,28 @@ def platform(aliased: bool = ..., terse: bool = ...) -> str: ... if sys.version_info >= (3, 10): def freedesktop_os_release() -> dict[str, str]: ... + +if sys.version_info >= (3, 13): + class AndroidVer(NamedTuple): + release: str + api_level: int + manufacturer: str + model: str + device: str + is_emulator: bool + + class IOSVersionInfo(NamedTuple): + system: str + release: str + model: str + is_simulator: bool + + def android_ver( + release: str = "", + api_level: int = 0, + manufacturer: str = "", + model: str = "", + device: str = "", + is_emulator: bool = False, + ) -> AndroidVer: ... + def ios_ver(system: str = "", release: str = "", model: str = "", is_simulator: bool = False) -> IOSVersionInfo: ... diff --git a/stdlib/tarfile.pyi b/stdlib/tarfile.pyi index b6fe454ef..e52099464 100644 --- a/stdlib/tarfile.pyi +++ b/stdlib/tarfile.pyi @@ -142,22 +142,43 @@ class TarFile: errorlevel: int | None offset: int # undocumented extraction_filter: _FilterFunction | None - def __init__( - self, - name: StrOrBytesPath | None = None, - mode: Literal["r", "a", "w", "x"] = "r", - fileobj: _Fileobj | None = None, - format: int | None = None, - tarinfo: type[TarInfo] | None = None, - dereference: bool | None = None, - ignore_zeros: bool | None = None, - encoding: str | None = None, - errors: str = "surrogateescape", - pax_headers: Mapping[str, str] | None = None, - debug: int | None = None, - errorlevel: int | None = None, - copybufsize: int | None = None, # undocumented - ) -> None: ... + if sys.version_info >= (3, 13): + stream: bool + def __init__( + self, + name: StrOrBytesPath | None = None, + mode: Literal["r", "a", "w", "x"] = "r", + fileobj: _Fileobj | None = None, + format: int | None = None, + tarinfo: type[TarInfo] | None = None, + dereference: bool | None = None, + ignore_zeros: bool | None = None, + encoding: str | None = None, + errors: str = "surrogateescape", + pax_headers: Mapping[str, str] | None = None, + debug: int | None = None, + errorlevel: int | None = None, + copybufsize: int | None = None, # undocumented + stream: bool = False, + ) -> None: ... + else: + def __init__( + self, + name: StrOrBytesPath | None = None, + mode: Literal["r", "a", "w", "x"] = "r", + fileobj: _Fileobj | None = None, + format: int | None = None, + tarinfo: type[TarInfo] | None = None, + dereference: bool | None = None, + ignore_zeros: bool | None = None, + encoding: str | None = None, + errors: str = "surrogateescape", + pax_headers: Mapping[str, str] | None = None, + debug: int | None = None, + errorlevel: int | None = None, + copybufsize: int | None = None, # undocumented + ) -> None: ... + def __enter__(self) -> Self: ... def __exit__( self, type: type[BaseException] | None, value: BaseException | None, traceback: TracebackType | None