Skip to content

Commit bc3155b

Browse files
jbosboomntninja
andcommitted
Implement os.statx
Co-authored-by: Erin of Yukis <erin-dev@ninetailed.ninja>
1 parent 4e4e917 commit bc3155b

9 files changed

Lines changed: 456 additions & 71 deletions

Include/internal/pycore_global_objects_fini_generated.h

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Include/internal/pycore_global_strings.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -571,6 +571,7 @@ struct _Py_global_strings {
571571
STRUCT_FOR_ID(loop)
572572
STRUCT_FOR_ID(manual_reset)
573573
STRUCT_FOR_ID(mapping)
574+
STRUCT_FOR_ID(mask)
574575
STRUCT_FOR_ID(match)
575576
STRUCT_FOR_ID(max_length)
576577
STRUCT_FOR_ID(maxdigits)
@@ -747,6 +748,7 @@ struct _Py_global_strings {
747748
STRUCT_FOR_ID(sub_key)
748749
STRUCT_FOR_ID(subcalls)
749750
STRUCT_FOR_ID(symmetric_difference_update)
751+
STRUCT_FOR_ID(sync)
750752
STRUCT_FOR_ID(tabsize)
751753
STRUCT_FOR_ID(tag)
752754
STRUCT_FOR_ID(target)

Include/internal/pycore_runtime_init_generated.h

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Include/internal/pycore_unicodeobject_generated.h

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Lib/os.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,8 @@ def _add(str, fn):
131131
_add("HAVE_UNLINKAT", "unlink")
132132
_add("HAVE_UNLINKAT", "rmdir")
133133
_add("HAVE_UTIMENSAT", "utime")
134+
if _exists("statx"):
135+
_set.add(statx)
134136
supports_dir_fd = _set
135137

136138
_set = set()
@@ -152,6 +154,8 @@ def _add(str, fn):
152154
_add("HAVE_FPATHCONF", "pathconf")
153155
if _exists("statvfs") and _exists("fstatvfs"): # mac os x10.3
154156
_add("HAVE_FSTATVFS", "statvfs")
157+
if _exists("statx"):
158+
_set.add(statx)
155159
supports_fd = _set
156160

157161
_set = set()
@@ -190,6 +194,8 @@ def _add(str, fn):
190194
_add("HAVE_FSTATAT", "stat")
191195
_add("HAVE_UTIMENSAT", "utime")
192196
_add("MS_WINDOWS", "stat")
197+
if _exists("statx"):
198+
_set.add(statx)
193199
supports_follow_symlinks = _set
194200

195201
del _set

Lib/stat.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,8 +200,8 @@ def filemode(mode):
200200
FILE_ATTRIBUTE_VIRTUAL = 65536
201201

202202

203-
# Linux STATX_ATTR constants for interpreting os.stat()'s
204-
# "st_attributes" and "st_attributes_mask" members
203+
# Linux STATX_ATTR constants for interpreting os.statx()'s
204+
# "stx_attributes" and "stx_attributes_mask" members
205205

206206
STATX_ATTR_COMPRESSED = 0x00000004
207207
STATX_ATTR_IMMUTABLE = 0x00000010
Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
Populate :attr:`~os.stat_result.st_birthtime`,
2-
:attr:`~os.stat_result.st_attributes`,
3-
:attr:`~os.stat_result.st_attributes_mask`,
4-
:attr:`~os.stat_result.st_mnt_id`, and :attr:`~os.stat_result.st_subvol`
5-
in :class:`os.stat_result` on Linux kernel 4.11 and later using the
6-
statx system call. Contributed by Jeffrey Bosboom.
1+
Provide :func:`os.statx` and populate :attr:`~os.stat_result.st_birthtime`
2+
in the return value of :func:`os.stat` on Linux kernel 4.11 and later using
3+
the statx system call. Contributed by Jeffrey Bosboom and Erin of Yukis.

Modules/clinic/posixmodule.c.h

Lines changed: 142 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)