Skip to content

Commit

Permalink
Put statx in correct os sets, and include in pythoninfo
Browse files Browse the repository at this point in the history
  • Loading branch information
zooba committed Nov 29, 2022
1 parent 8ee94aa commit bbcc6ee
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
8 changes: 8 additions & 0 deletions Lib/os.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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
Expand Down Expand Up @@ -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:
Expand Down
2 changes: 2 additions & 0 deletions Lib/test/pythoninfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down

0 comments on commit bbcc6ee

Please sign in to comment.