From 6f2c53f3b0d5472a1dd655dcb366be9e833dbb7d Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Thu, 19 May 2022 05:43:58 -0700 Subject: [PATCH] _imp: fix stubtest issues, add Python 3.11 items (#7878) --- stdlib/_imp.pyi | 10 +++++++++- tests/stubtest_allowlists/py310.txt | 1 - tests/stubtest_allowlists/py311.txt | 4 ---- tests/stubtest_allowlists/py37.txt | 1 - tests/stubtest_allowlists/py38.txt | 1 - tests/stubtest_allowlists/py39.txt | 1 - 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/stdlib/_imp.pyi b/stdlib/_imp.pyi index e2bbb9385..856188dfb 100644 --- a/stdlib/_imp.pyi +++ b/stdlib/_imp.pyi @@ -1,10 +1,12 @@ import sys import types +from _typeshed import ReadableBuffer from importlib.machinery import ModuleSpec from typing import Any if sys.version_info >= (3, 7): check_hash_based_pycs: str + def source_hash(key: int, source: ReadableBuffer) -> bytes: ... def create_builtin(__spec: ModuleSpec) -> types.ModuleType: ... def create_dynamic(__spec: ModuleSpec, __file: Any = ...) -> types.ModuleType: ... @@ -12,10 +14,16 @@ def acquire_lock() -> None: ... def exec_builtin(__mod: types.ModuleType) -> int: ... def exec_dynamic(__mod: types.ModuleType) -> int: ... def extension_suffixes() -> list[str]: ... -def get_frozen_object(__name: str) -> types.CodeType: ... def init_frozen(__name: str) -> types.ModuleType: ... def is_builtin(__name: str) -> int: ... def is_frozen(__name: str) -> bool: ... def is_frozen_package(__name: str) -> bool: ... def lock_held() -> bool: ... def release_lock() -> None: ... + +if sys.version_info >= (3, 11): + def find_frozen(__name: str, *, withdata: bool = ...) -> tuple[memoryview | None, bool, str | None] | None: ... + def get_frozen_object(__name: str, __data: ReadableBuffer | None = ...) -> types.CodeType: ... + +else: + def get_frozen_object(__name: str) -> types.CodeType: ... diff --git a/tests/stubtest_allowlists/py310.txt b/tests/stubtest_allowlists/py310.txt index b24e54826..7f836123f 100644 --- a/tests/stubtest_allowlists/py310.txt +++ b/tests/stubtest_allowlists/py310.txt @@ -81,7 +81,6 @@ _collections_abc.Iterable.__class_getitem__ _collections_abc.MappingView.__class_getitem__ _csv.Reader _csv.Writer -_imp.source_hash asynchat.__warningregistry__ # Removal planned for 3.12, can add if someone needs this bdb.Breakpoint.clearBreakpoints distutils.dist.DistributionMetadata.set_classifiers diff --git a/tests/stubtest_allowlists/py311.txt b/tests/stubtest_allowlists/py311.txt index 001aa6d5d..b8168fab6 100644 --- a/tests/stubtest_allowlists/py311.txt +++ b/tests/stubtest_allowlists/py311.txt @@ -13,9 +13,6 @@ _collections_abc.MappingView.__class_getitem__ _collections_abc.ValuesView.__reversed__ _csv.Reader _csv.Writer -_imp.find_frozen -_imp.get_frozen_object -_imp.source_hash _operator.attrgetter.__vectorcalloffset__ _operator.itemgetter.__vectorcalloffset__ argparse._AppendConstAction.__init__ @@ -65,7 +62,6 @@ fractions.Fraction.__new__ # overload is too complicated for stubtest to resolv ftplib.FTP.trust_server_pasv_ipv4_address functools.partial.__vectorcalloffset__ gettext.install -imp.get_frozen_object importlib.resources.Resource inspect._ParameterKind.description ipaddress.IPv4Interface.hostmask diff --git a/tests/stubtest_allowlists/py37.txt b/tests/stubtest_allowlists/py37.txt index 420b30ef3..6db13c226 100644 --- a/tests/stubtest_allowlists/py37.txt +++ b/tests/stubtest_allowlists/py37.txt @@ -89,7 +89,6 @@ tempfile.SpooledTemporaryFile.writable # Exists at runtime, but missing from stubs _dummy_thread.RLock -_imp.source_hash contextvars.ContextVar.__class_getitem__ datetime.datetime_CAPI distutils.dist.DistributionMetadata.set_classifiers diff --git a/tests/stubtest_allowlists/py38.txt b/tests/stubtest_allowlists/py38.txt index 1b490fbbd..b13fa07e4 100644 --- a/tests/stubtest_allowlists/py38.txt +++ b/tests/stubtest_allowlists/py38.txt @@ -105,7 +105,6 @@ tempfile.SpooledTemporaryFile.writable # Exists at runtime, but missing from stubs _dummy_thread.RLock -_imp.source_hash contextvars.ContextVar.__class_getitem__ datetime.datetime_CAPI distutils.dist.DistributionMetadata.set_classifiers diff --git a/tests/stubtest_allowlists/py39.txt b/tests/stubtest_allowlists/py39.txt index 8e25b723c..d607f8db8 100644 --- a/tests/stubtest_allowlists/py39.txt +++ b/tests/stubtest_allowlists/py39.txt @@ -109,7 +109,6 @@ _collections_abc.Awaitable.__class_getitem__ _collections_abc.Container.__class_getitem__ _collections_abc.Iterable.__class_getitem__ _collections_abc.MappingView.__class_getitem__ -_imp.source_hash collections.AsyncIterable.__class_getitem__ collections.Awaitable.__class_getitem__ collections.Container.__class_getitem__