diff --git a/stdlib/@tests/stubtest_allowlists/darwin.txt b/stdlib/@tests/stubtest_allowlists/darwin.txt index ba8a5c4c6..aeb4fd7ee 100644 --- a/stdlib/@tests/stubtest_allowlists/darwin.txt +++ b/stdlib/@tests/stubtest_allowlists/darwin.txt @@ -24,11 +24,6 @@ select.POLLMSG # system dependent (posix.ST_[A-Z]+)? (termios.[A-Z0-9_]+)? -# Exists at runtime, but missing from stubs -_ctypes.dlclose -_ctypes.dlopen -_ctypes.dlsym - # ========== # Allowlist entries that cannot or should not be fixed # ========== diff --git a/stdlib/@tests/stubtest_allowlists/linux.txt b/stdlib/@tests/stubtest_allowlists/linux.txt index 74a7d1826..ad8924a23 100644 --- a/stdlib/@tests/stubtest_allowlists/linux.txt +++ b/stdlib/@tests/stubtest_allowlists/linux.txt @@ -5,10 +5,6 @@ curses.has_key selectors.KqueueSelector -_ctypes.dlclose -_ctypes.dlopen -_ctypes.dlsym - # ========== # Allowlist entries that cannot or should not be fixed # ========== diff --git a/stdlib/_ctypes.pyi b/stdlib/_ctypes.pyi index a1df1751b..b4c433fa5 100644 --- a/stdlib/_ctypes.pyi +++ b/stdlib/_ctypes.pyi @@ -1,6 +1,6 @@ import _typeshed import sys -from _typeshed import ReadableBuffer, WriteableBuffer +from _typeshed import ReadableBuffer, StrOrBytesPath, WriteableBuffer from abc import abstractmethod from collections.abc import Callable, Iterable, Iterator, Mapping, Sequence from ctypes import CDLL, ArgumentError as ArgumentError, c_void_p @@ -48,6 +48,12 @@ if sys.platform == "win32": def LoadLibrary(name: str, load_flags: int = 0, /) -> int: ... def FreeLibrary(handle: int, /) -> None: ... +else: + def dlclose(handle: int, /) -> None: ... + # The default for flag is RTLD_GLOBAL|RTLD_LOCAL, which is platform dependent. + def dlopen(name: StrOrBytesPath, flag: int = ..., /) -> int: ... + def dlsym(handle: int, name: str, /) -> int: ... + if sys.version_info >= (3, 13): # This class is not exposed. It calls itself _ctypes.CType_Type. @type_check_only