From 20bc8fa4e30df5f879606dfc37dd0b4bcebaeedd Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Thu, 15 Sep 2022 23:27:42 +0100 Subject: [PATCH] Fix stubtest errors on macOS / Python 3.11 (#8743) --- stdlib/os/__init__.pyi | 6 +++--- stdlib/posix.pyi | 11 ++--------- tests/stubtest_allowlists/darwin-py311.txt | 8 ++++++++ tests/stubtest_allowlists/darwin.txt | 6 +++++- 4 files changed, 18 insertions(+), 13 deletions(-) diff --git a/stdlib/os/__init__.pyi b/stdlib/os/__init__.pyi index a7567caca..6f51d4e7a 100644 --- a/stdlib/os/__init__.pyi +++ b/stdlib/os/__init__.pyi @@ -607,7 +607,6 @@ def pipe() -> tuple[int, int]: ... def read(__fd: int, __length: int) -> bytes: ... if sys.platform != "win32": - # Unix only def fchmod(fd: int, mode: int) -> None: ... def fchown(fd: int, uid: int, gid: int) -> None: ... def fpathconf(__fd: int, __name: str | int) -> int: ... @@ -624,11 +623,12 @@ if sys.platform != "win32": def pread(__fd: int, __length: int, __offset: int) -> bytes: ... def pwrite(__fd: int, __buffer: bytes, __offset: int) -> int: ... + # In CI, stubtest sometimes reports that these are available on MacOS, sometimes not + def preadv(__fd: int, __buffers: SupportsLenAndGetItem[WriteableBuffer], __offset: int, __flags: int = ...) -> int: ... + def pwritev(__fd: int, __buffers: SupportsLenAndGetItem[ReadableBuffer], __offset: int, __flags: int = ...) -> int: ... if sys.platform != "darwin": if sys.version_info >= (3, 10): RWF_APPEND: int # docs say available on 3.7+, stubtest says otherwise - def preadv(__fd: int, __buffers: SupportsLenAndGetItem[WriteableBuffer], __offset: int, __flags: int = ...) -> int: ... - def pwritev(__fd: int, __buffers: SupportsLenAndGetItem[ReadableBuffer], __offset: int, __flags: int = ...) -> int: ... RWF_DSYNC: int RWF_SYNC: int RWF_HIPRI: int diff --git a/stdlib/posix.pyi b/stdlib/posix.pyi index 7055f15f3..ffd967575 100644 --- a/stdlib/posix.pyi +++ b/stdlib/posix.pyi @@ -309,17 +309,10 @@ if sys.platform != "win32": copy_file_range as copy_file_range, memfd_create as memfd_create, ) - from os import register_at_fork as register_at_fork + from os import preadv as preadv, pwritev as pwritev, register_at_fork as register_at_fork if sys.platform != "darwin": - from os import ( - RWF_DSYNC as RWF_DSYNC, - RWF_HIPRI as RWF_HIPRI, - RWF_NOWAIT as RWF_NOWAIT, - RWF_SYNC as RWF_SYNC, - preadv as preadv, - pwritev as pwritev, - ) + from os import RWF_DSYNC as RWF_DSYNC, RWF_HIPRI as RWF_HIPRI, RWF_NOWAIT as RWF_NOWAIT, RWF_SYNC as RWF_SYNC # Not same as os.environ or os.environb # Because of this variable, we can't do "from posix import *" in os/__init__.pyi diff --git a/tests/stubtest_allowlists/darwin-py311.txt b/tests/stubtest_allowlists/darwin-py311.txt index c1d55d979..a2f7f5a42 100644 --- a/tests/stubtest_allowlists/darwin-py311.txt +++ b/tests/stubtest_allowlists/darwin-py311.txt @@ -3,3 +3,11 @@ xxlimited.Xxo.x_exports # Exists at runtime, missing from stub socket.TCP_CONNECTION_INFO + +(dbm.gnu)? +(locale.bind_textdomain_codeset)? +(locale.bindtextdomain)? +(locale.dcgettext) +(locale.dgettext)? +(locale.gettext)? +(locale.textdomain)? \ No newline at end of file diff --git a/tests/stubtest_allowlists/darwin.txt b/tests/stubtest_allowlists/darwin.txt index f9896b6ed..6e8ef83e6 100644 --- a/tests/stubtest_allowlists/darwin.txt +++ b/tests/stubtest_allowlists/darwin.txt @@ -12,10 +12,14 @@ select.KQ_FILTER_NETDEV # system dependent select.kqueue.__init__ # default C signature is wrong select.POLLMSG # system dependent -# Sometimes this exists on darwin, sometimes not +# Sometimes these seem to exist on darwin, sometimes not (_socket.MSG_NOSIGNAL)? (socket.MsgFlag.MSG_NOSIGNAL)? (socket.MSG_NOSIGNAL)? +(os.preadv)? +(os.pwritev)? +(posix.preadv)? +(posix.pwritev)? # Exists at runtime, but missing from stubs distutils.msvccompiler.MSVCCompiler.get_msvc_paths