Skip to content

Commit 12c49f7

Browse files
committed
Simplify posixmodule.c macros
Remove now redundant MEMBER parameter.
1 parent 1f0a688 commit 12c49f7

File tree

2 files changed

+38
-25
lines changed

2 files changed

+38
-25
lines changed

Doc/library/os.rst

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3497,6 +3497,9 @@ features:
34973497
Number of 512-byte blocks allocated for file.
34983498
This may be smaller than :attr:`stx_size`/512 when the file has holes.
34993499

3500+
Equal to ``None`` if :data:`STATX_BLOCKS` is missing from
3501+
:attr:`~statx_result.stx_mask`.
3502+
35003503
.. attribute:: stx_btime
35013504

35023505
Time of file creation expressed in seconds.
@@ -3572,9 +3575,15 @@ features:
35723575

35733576
Group identifier of the file owner.
35743577

3578+
Equal to ``None`` if :data:`STATX_GID` is missing from
3579+
:attr:`~statx_result.stx_mask`.
3580+
35753581
.. attribute:: stx_ino
35763582

3577-
The inode number.
3583+
Inode number.
3584+
3585+
Equal to ``None`` if :data:`STATX_INO` is missing from
3586+
:attr:`~statx_result.stx_mask`.
35783587

35793588
.. attribute:: stx_mnt_id
35803589

@@ -3609,6 +3618,9 @@ features:
36093618

36103619
Number of hard links.
36113620

3621+
Equal to ``None`` if :data:`STATX_NLINK` is missing from
3622+
:attr:`~statx_result.stx_mask`.
3623+
36123624
.. attribute:: stx_rdev
36133625

36143626
Type of device if an inode device.
@@ -3627,6 +3639,9 @@ features:
36273639
The size of a symbolic link is the length of the pathname it contains,
36283640
without a terminating null byte.
36293641

3642+
Equal to ``None`` if :data:`STATX_SIZE` is missing from
3643+
:attr:`~statx_result.stx_mask`.
3644+
36303645
.. attribute:: stx_subvol
36313646

36323647
Subvolume identifier.
@@ -3641,6 +3656,9 @@ features:
36413656

36423657
User identifier of the file owner.
36433658

3659+
Equal to ``None`` if :data:`STATX_UID` is missing from
3660+
:attr:`~statx_result.stx_mask`.
3661+
36443662
.. seealso:: The :manpage:`statx(2)` man page.
36453663

36463664
.. availability:: Linux >= 4.11 with glibc >= 2.28.

Modules/posixmodule.c

Lines changed: 19 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3349,63 +3349,58 @@ static PyMemberDef pystatx_result_members[] = {
33493349
#undef M
33503350

33513351

3352-
#define STATX_GET_UINT(ATTR, MEMBER, MASK) \
3352+
#define STATX_GET_UINT(ATTR, MASK) \
33533353
static PyObject* \
33543354
pystatx_result_get_##ATTR(PyObject *op, void *Py_UNUSED(context)) \
33553355
{ \
33563356
Py_statx_result *self = Py_statx_result_CAST(op); \
33573357
if (!(self->stx.stx_mask & MASK)) { \
33583358
Py_RETURN_NONE; \
33593359
} \
3360-
unsigned long value = self->stx.MEMBER; \
3360+
unsigned long value = self->stx.ATTR; \
33613361
return PyLong_FromUnsignedLong(value); \
33623362
}
33633363

3364-
STATX_GET_UINT(stx_uid, stx_uid, STATX_UID)
3365-
STATX_GET_UINT(stx_gid, stx_gid, STATX_GID)
3366-
STATX_GET_UINT(stx_nlink, stx_nlink, STATX_NLINK)
3364+
STATX_GET_UINT(stx_uid, STATX_UID)
3365+
STATX_GET_UINT(stx_gid, STATX_GID)
3366+
STATX_GET_UINT(stx_nlink, STATX_NLINK)
33673367
#ifdef HAVE_STRUCT_STATX_STX_DIO_MEM_ALIGN
3368-
STATX_GET_UINT(stx_dio_mem_align, stx_dio_mem_align, STATX_DIOALIGN)
3369-
STATX_GET_UINT(stx_dio_offset_align, stx_dio_offset_align, STATX_DIOALIGN)
3368+
STATX_GET_UINT(stx_dio_mem_align, STATX_DIOALIGN)
3369+
STATX_GET_UINT(stx_dio_offset_align, STATX_DIOALIGN)
33703370
#endif
33713371
#ifdef HAVE_STRUCT_STATX_STX_DIO_READ_OFFSET_ALIGN
3372-
STATX_GET_UINT(stx_dio_read_offset_align, stx_dio_read_offset_align,
3373-
STATX_DIO_READ_ALIGN)
3372+
STATX_GET_UINT(stx_dio_read_offset_align, STATX_DIO_READ_ALIGN)
33743373
#endif
33753374
#ifdef HAVE_STRUCT_STATX_STX_ATOMIC_WRITE_UNIT_MIN
3376-
STATX_GET_UINT(stx_atomic_write_unit_min, stx_atomic_write_unit_min,
3377-
STATX_WRITE_ATOMIC)
3378-
STATX_GET_UINT(stx_atomic_write_unit_max, stx_atomic_write_unit_max,
3379-
STATX_WRITE_ATOMIC)
3380-
STATX_GET_UINT(stx_atomic_write_segments_max, stx_atomic_write_segments_max,
3381-
STATX_WRITE_ATOMIC)
3375+
STATX_GET_UINT(stx_atomic_write_unit_min, STATX_WRITE_ATOMIC)
3376+
STATX_GET_UINT(stx_atomic_write_unit_max, STATX_WRITE_ATOMIC)
3377+
STATX_GET_UINT(stx_atomic_write_segments_max, STATX_WRITE_ATOMIC)
33823378
#endif
33833379
#ifdef HAVE_STRUCT_STATX_STX_ATOMIC_WRITE_UNIT_MAX_OPT
3384-
STATX_GET_UINT(stx_atomic_write_unit_max_opt, stx_atomic_write_unit_max_opt,
3385-
STATX_WRITE_ATOMIC)
3380+
STATX_GET_UINT(stx_atomic_write_unit_max_opt, STATX_WRITE_ATOMIC)
33863381
#endif
33873382

33883383

3389-
#define STATX_GET_ULONGLONG(ATTR, MEMBER, MASK) \
3384+
#define STATX_GET_ULONGLONG(ATTR, MASK) \
33903385
static PyObject* \
33913386
pystatx_result_get_##ATTR(PyObject *op, void *Py_UNUSED(context)) \
33923387
{ \
33933388
Py_statx_result *self = Py_statx_result_CAST(op); \
33943389
if (!(self->stx.stx_mask & MASK)) { \
33953390
Py_RETURN_NONE; \
33963391
} \
3397-
unsigned long long value = self->stx.MEMBER; \
3392+
unsigned long long value = self->stx.ATTR; \
33983393
return PyLong_FromUnsignedLongLong(value); \
33993394
}
34003395

3401-
STATX_GET_ULONGLONG(stx_blocks, stx_blocks, STATX_BLOCKS)
3402-
STATX_GET_ULONGLONG(stx_ino, stx_ino, STATX_INO)
3403-
STATX_GET_ULONGLONG(stx_size, stx_size, STATX_SIZE)
3396+
STATX_GET_ULONGLONG(stx_blocks, STATX_BLOCKS)
3397+
STATX_GET_ULONGLONG(stx_ino, STATX_INO)
3398+
STATX_GET_ULONGLONG(stx_size, STATX_SIZE)
34043399
#ifdef HAVE_STRUCT_STATX_STX_MNT_ID
3405-
STATX_GET_ULONGLONG(stx_mnt_id, stx_mnt_id, STATX_MNT_ID)
3400+
STATX_GET_ULONGLONG(stx_mnt_id, STATX_MNT_ID)
34063401
#endif
34073402
#ifdef HAVE_STRUCT_STATX_STX_SUBVOL
3408-
STATX_GET_ULONGLONG(stx_subvol, stx_subvol, STATX_SUBVOL)
3403+
STATX_GET_ULONGLONG(stx_subvol, STATX_SUBVOL)
34093404
#endif
34103405

34113406

0 commit comments

Comments
 (0)