From b0a391714512389f3fc73f2a3b6f047c4bdeeb09 Mon Sep 17 00:00:00 2001 From: Nikita Sobolev Date: Wed, 7 Jun 2023 22:33:50 +0300 Subject: [PATCH] Update dis.pyi and opcode.pyi for Python3.12 (#10276) --- stdlib/dis.pyi | 5 ++++- stdlib/opcode.pyi | 12 +++++++++--- tests/stubtest_allowlists/py312.txt | 8 -------- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/stdlib/dis.pyi b/stdlib/dis.pyi index d153771e6..ab101a517 100644 --- a/stdlib/dis.pyi +++ b/stdlib/dis.pyi @@ -29,9 +29,12 @@ __all__ = [ "opmap", "HAVE_ARGUMENT", "EXTENDED_ARG", - "hasnargs", "stack_effect", ] +if sys.version_info >= (3, 12): + __all__ += ["hasarg", "hasexc"] +else: + __all__ += ["hasnargs"] # Strictly this should not have to include Callable, but mypy doesn't use FunctionType # for functions (python/mypy#3171) diff --git a/stdlib/opcode.pyi b/stdlib/opcode.pyi index 1232454e7..f852489ff 100644 --- a/stdlib/opcode.pyi +++ b/stdlib/opcode.pyi @@ -14,9 +14,12 @@ __all__ = [ "opmap", "HAVE_ARGUMENT", "EXTENDED_ARG", - "hasnargs", "stack_effect", ] +if sys.version_info >= (3, 12): + __all__ += ["hasarg", "hasexc"] +else: + __all__ += ["hasnargs"] if sys.version_info >= (3, 9): cmp_op: tuple[Literal["<"], Literal["<="], Literal["=="], Literal["!="], Literal[">"], Literal[">="]] @@ -42,6 +45,11 @@ hasjabs: list[int] haslocal: list[int] hascompare: list[int] hasfree: list[int] +if sys.version_info >= (3, 12): + hasarg: list[int] + hasexc: list[int] +else: + hasnargs: list[int] opname: list[str] opmap: dict[str, int] @@ -53,5 +61,3 @@ if sys.version_info >= (3, 8): else: def stack_effect(__opcode: int, __oparg: int | None = None) -> int: ... - -hasnargs: list[int] diff --git a/tests/stubtest_allowlists/py312.txt b/tests/stubtest_allowlists/py312.txt index 4429ba53f..5df6b7235 100644 --- a/tests/stubtest_allowlists/py312.txt +++ b/tests/stubtest_allowlists/py312.txt @@ -25,10 +25,6 @@ configparser.RawConfigParser.readfp configparser.__all__ ctypes.c_time_t datetime.__all__ -dis.__all__ -dis.hasarg -dis.hasexc -dis.hasnargs email.utils.localtime enum.Enum.__signature__ enum.EnumMeta.__call__ @@ -87,10 +83,6 @@ multiprocessing.queues.Queue.__class_getitem__ ntpath.__all__ ntpath.isjunction ntpath.splitroot -opcode.__all__ -opcode.hasarg -opcode.hasexc -opcode.hasnargs os.DirEntry.is_junction os.path.__all__ os.path.isjunction