From 1c6eb33c2302eb5c943f5f8bd62a2c1faf967412 Mon Sep 17 00:00:00 2001 From: junkmd <45822440+junkmd@users.noreply.github.com> Date: Mon, 29 Aug 2022 23:33:47 +0900 Subject: [PATCH] add and migrate constants from `ctypes/__init__.pyi` to `_ctypes.pyi` (#8643) Co-authored-by: Alex Waygood Co-authored-by: Akuli --- stdlib/_ctypes.pyi | 7 +++++++ stdlib/ctypes/__init__.pyi | 6 ++++-- tests/stubtest_allowlists/py3_common.txt | 6 ------ 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/stdlib/_ctypes.pyi b/stdlib/_ctypes.pyi index 99e3ea52a..0ad2fcb57 100644 --- a/stdlib/_ctypes.pyi +++ b/stdlib/_ctypes.pyi @@ -2,6 +2,13 @@ import sys from ctypes import _CArgObject, _PointerLike from typing_extensions import TypeAlias +FUNCFLAG_CDECL: int +FUNCFLAG_PYTHONAPI: int +FUNCFLAG_USE_ERRNO: int +FUNCFLAG_USE_LASTERROR: int +RTLD_GLOBAL: int +RTLD_LOCAL: int + if sys.version_info >= (3, 11): CTYPES_MAX_ARGCOUNT: int diff --git a/stdlib/ctypes/__init__.pyi b/stdlib/ctypes/__init__.pyi index 48694fc6c..19465e084 100644 --- a/stdlib/ctypes/__init__.pyi +++ b/stdlib/ctypes/__init__.pyi @@ -5,6 +5,10 @@ from collections.abc import Callable, Iterable, Iterator, Mapping, Sequence from typing import Any, ClassVar, Generic, TypeVar, Union as _UnionT, overload from typing_extensions import TypeAlias +# TODO: import these from _ctypes once it no longer breaks pytype +RTLD_GLOBAL: int +RTLD_LOCAL: int + if sys.version_info >= (3, 9): from types import GenericAlias @@ -12,8 +16,6 @@ _T = TypeVar("_T") _DLLT = TypeVar("_DLLT", bound=CDLL) _CT = TypeVar("_CT", bound=_CData) -RTLD_GLOBAL: int -RTLD_LOCAL: int DEFAULT_MODE: int class CDLL: diff --git a/tests/stubtest_allowlists/py3_common.txt b/tests/stubtest_allowlists/py3_common.txt index aeccb4be2..62edc2a51 100644 --- a/tests/stubtest_allowlists/py3_common.txt +++ b/tests/stubtest_allowlists/py3_common.txt @@ -341,16 +341,10 @@ wave.Wave_write.initfp _ctypes.Array _ctypes.CFuncPtr -_ctypes.FUNCFLAG_CDECL -_ctypes.FUNCFLAG_PYTHONAPI -_ctypes.FUNCFLAG_USE_ERRNO -_ctypes.FUNCFLAG_USE_LASTERROR _ctypes.POINTER _ctypes.PyObj_FromPtr _ctypes.Py_DECREF _ctypes.Py_INCREF -_ctypes.RTLD_GLOBAL -_ctypes.RTLD_LOCAL _ctypes.Structure _ctypes.Union _ctypes.addressof