From 7fc9b8e2c8fc7942847103c53418a90050f65791 Mon Sep 17 00:00:00 2001 From: Avasam Date: Sat, 12 Nov 2022 18:56:43 -0500 Subject: [PATCH] `cffi`: run stubtest on Windows (#9178) --- stubs/cffi/@tests/stubtest_allowlist.txt | 5 +---- stubs/cffi/@tests/stubtest_allowlist_darwin.txt | 2 ++ stubs/cffi/@tests/stubtest_allowlist_linux.txt | 2 ++ stubs/cffi/METADATA.toml | 2 ++ stubs/cffi/_cffi_backend.pyi | 3 ++- stubs/cffi/cffi/api.pyi | 1 + 6 files changed, 10 insertions(+), 5 deletions(-) create mode 100644 stubs/cffi/@tests/stubtest_allowlist_darwin.txt create mode 100644 stubs/cffi/@tests/stubtest_allowlist_linux.txt diff --git a/stubs/cffi/@tests/stubtest_allowlist.txt b/stubs/cffi/@tests/stubtest_allowlist.txt index 888455088..7a2812d7f 100644 --- a/stubs/cffi/@tests/stubtest_allowlist.txt +++ b/stubs/cffi/@tests/stubtest_allowlist.txt @@ -1,6 +1,3 @@ -# technically exists on all OSs, but crashes on all but windows -cffi.(api.)?FFI.getwinerror - # added dynamically and not detected by stubtest cffi.(api.)?FFI.CData cffi.(api.)?FFI.CType @@ -11,4 +8,4 @@ cffi.vengine_cpy.__warningregistry__ # Unnecessary re-exports cffi.cparser.COMMON_TYPES -cffi.verifier.__version_verifier_modules__ \ No newline at end of file +cffi.verifier.__version_verifier_modules__ diff --git a/stubs/cffi/@tests/stubtest_allowlist_darwin.txt b/stubs/cffi/@tests/stubtest_allowlist_darwin.txt new file mode 100644 index 000000000..55d4b889a --- /dev/null +++ b/stubs/cffi/@tests/stubtest_allowlist_darwin.txt @@ -0,0 +1,2 @@ +# Technically exists on all OSs, but crashes on all but Windows. So we hide it in stubs +cffi.(api.)?FFI.getwinerror diff --git a/stubs/cffi/@tests/stubtest_allowlist_linux.txt b/stubs/cffi/@tests/stubtest_allowlist_linux.txt new file mode 100644 index 000000000..55d4b889a --- /dev/null +++ b/stubs/cffi/@tests/stubtest_allowlist_linux.txt @@ -0,0 +1,2 @@ +# Technically exists on all OSs, but crashes on all but Windows. So we hide it in stubs +cffi.(api.)?FFI.getwinerror diff --git a/stubs/cffi/METADATA.toml b/stubs/cffi/METADATA.toml index 0857c7852..1c348f18b 100644 --- a/stubs/cffi/METADATA.toml +++ b/stubs/cffi/METADATA.toml @@ -2,3 +2,5 @@ version = "1.15.*" [tool.stubtest] ignore_missing_stub = false +# linux and darwin are mostly equivalent, except for a single `RTLD_DEEPBIND` variable +platforms = ["linux", "win32"] diff --git a/stubs/cffi/_cffi_backend.pyi b/stubs/cffi/_cffi_backend.pyi index ecee297fd..05d12ff35 100644 --- a/stubs/cffi/_cffi_backend.pyi +++ b/stubs/cffi/_cffi_backend.pyi @@ -18,8 +18,9 @@ RTLD_GLOBAL: int RTLD_LAZY: int RTLD_LOCAL: int RTLD_NOW: int -if sys.platform != "win32": +if sys.platform == "linux": RTLD_DEEPBIND: int +if sys.platform != "win32": RTLD_NODELETE: int RTLD_NOLOAD: int diff --git a/stubs/cffi/cffi/api.pyi b/stubs/cffi/cffi/api.pyi index 751f7d1fd..2c929dd65 100644 --- a/stubs/cffi/cffi/api.pyi +++ b/stubs/cffi/cffi/api.pyi @@ -72,6 +72,7 @@ class FFI: @overload def gc(self, cdata: CData, destructor: None, size: int = ...) -> None: ... def verify(self, source: str = ..., tmpdir: str | None = ..., **kwargs: Any) -> _cffi_backend.Lib: ... + # Technically exists on all OSs, but crashes on all but Windows. So we hide it in stubs if sys.platform == "win32": def getwinerror(self, code: int = ...) -> tuple[int, str] | None: ...