Skip to content

add and migrate constants from ctypes/__init__.pyi to _ctypes.pyi #8643

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions stdlib/_ctypes.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 4 additions & 2 deletions stdlib/ctypes/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,17 @@ 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

_T = TypeVar("_T")
_DLLT = TypeVar("_DLLT", bound=CDLL)
_CT = TypeVar("_CT", bound=_CData)

RTLD_GLOBAL: int
RTLD_LOCAL: int
DEFAULT_MODE: int

class CDLL:
Expand Down
6 changes: 0 additions & 6 deletions tests/stubtest_allowlists/py3_common.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down