From bbcc6ee817e2b62ff533e4445a9e427759dde557 Mon Sep 17 00:00:00 2001 From: Steve Dower Date: Tue, 29 Nov 2022 21:32:52 +0000 Subject: [PATCH] Put statx in correct os sets, and include in pythoninfo --- Lib/os.py | 8 ++++++++ Lib/test/pythoninfo.py | 2 ++ 2 files changed, 10 insertions(+) diff --git a/Lib/os.py b/Lib/os.py index de6324edec42ce..e0ce7d426a38e0 100644 --- a/Lib/os.py +++ b/Lib/os.py @@ -118,6 +118,7 @@ def _add(str, fn): _add("HAVE_OPENAT", "open") _add("HAVE_READLINKAT", "readlink") _add("HAVE_RENAMEAT", "rename") + _add("HAVE_STATX", "statx") _add("HAVE_SYMLINKAT", "symlink") _add("HAVE_UNLINKAT", "unlink") _add("HAVE_UNLINKAT", "rmdir") @@ -140,6 +141,7 @@ def _add(str, fn): _add("HAVE_FUTIMENS", "utime") _add("HAVE_FUTIMES", "utime") _add("HAVE_FPATHCONF", "pathconf") + _add("HAVE_STATX", "statx") if _exists("statvfs") and _exists("fstatvfs"): # mac os x10.3 _add("HAVE_FSTATVFS", "statvfs") supports_fd = _set @@ -1099,6 +1101,12 @@ def statx(path, mask, *, dir_fd=None, follow_symlinks=True, flags=0): """ return (stat if follow_symlinks else lstat)(path, dir_fd=dir_fd) + # Ensure our supports sets include us based on the fallback functions + supports_fd.add(statx) + if stat in supports_follow_symlinks: + supports_follow_symlinks.add(statx) + if stat in supports_dir_fd: + supports_dir_fd.add(statx) if name == 'nt': class _AddedDllDirectory: diff --git a/Lib/test/pythoninfo.py b/Lib/test/pythoninfo.py index adc211b3e2169c..480ff0a815556d 100644 --- a/Lib/test/pythoninfo.py +++ b/Lib/test/pythoninfo.py @@ -213,6 +213,8 @@ def format_attr(attr, value): ) copy_attributes(info_add, os, 'os.%s', attributes, formatter=format_attr) + info_add('os.HAVE_STATX', hasattr(sys.modules[os.name], 'statx')) + for func in ( 'cpu_count', 'getcwd',