Fix platform availability of some Unix constants (#10857)

This commit is contained in:
Alex Waygood
2023-10-08 00:05:20 +02:00
committed by GitHub
parent 8acf1944f3
commit e4edcf23e0
6 changed files with 22 additions and 20 deletions

View File

@@ -70,9 +70,20 @@ if sys.platform != "win32":
POSIX_FADV_WILLNEED: int
POSIX_FADV_DONTNEED: int
SF_NODISKIO: int
SF_MNOWAIT: int
SF_SYNC: int
if sys.platform != "linux" and sys.platform != "darwin":
# In the os-module docs, these are marked as being available
# on "Unix, not Emscripten, not WASI."
# However, in the source code, a comment indicates they're "FreeBSD constants".
# sys.platform could have one of many values on a FreeBSD Python build,
# so the sys-module docs recommend doing `if sys.platform.startswith('freebsd')`
# to detect FreeBSD builds. Unfortunately that would be too dynamic
# for type checkers, however.
SF_NODISKIO: int
SF_MNOWAIT: int
SF_SYNC: int
if sys.version_info >= (3, 11):
SF_NOCACHE: int
if sys.platform == "linux":
XATTR_SIZE_MAX: int