Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 7e8e183

Browse files
authored
Merge branch 'main' into distribution-from-name-break-exc-chain
2 parents a5955c1 + 728d239 commit 7e8e183

53 files changed

Lines changed: 1372 additions & 192 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Doc/c-api/bytes.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,7 @@ Create, Finish, Discard
259259
If *size* is greater than zero, allocate *size* bytes, and set the
260260
writer size to *size*. The caller is responsible to write *size*
261261
bytes using :c:func:`PyBytesWriter_GetData`.
262+
This function does not overallocate.
262263
263264
On error, set an exception and return ``NULL``.
264265
@@ -349,6 +350,8 @@ Low-level API
349350
350351
Resize the writer to *size* bytes. It can be used to enlarge or to
351352
shrink the writer.
353+
This function typically overallocates to achieve amortized performance when
354+
resizing multiple times.
352355
353356
Newly allocated bytes are left uninitialized.
354357
@@ -360,6 +363,8 @@ Low-level API
360363
.. c:function:: int PyBytesWriter_Grow(PyBytesWriter *writer, Py_ssize_t grow)
361364
362365
Resize the writer by adding *grow* bytes to the current writer size.
366+
This function typically overallocates to achieve amortized performance when
367+
resizing multiple times.
363368
364369
Newly allocated bytes are left uninitialized.
365370

Doc/deprecations/pending-removal-in-3.20.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,6 @@ Pending removal in Python 3.20
1919
- :mod:`tabnanny`
2020
- :mod:`tkinter.font`
2121
- :mod:`tkinter.ttk`
22+
- :mod:`zlib`
2223

23-
(Contributed by Hugo van Kemenade in :gh:`76007`.)
24+
(Contributed by Hugo van Kemenade and Stan Ulbrych in :gh:`76007`.)

Doc/library/os.rst

Lines changed: 208 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3383,6 +3383,214 @@ features:
33833383
Added the :attr:`st_birthtime` member on Windows.
33843384

33853385

3386+
.. function:: statx(path, mask, *, flags=0, dir_fd=None, follow_symlinks=True)
3387+
3388+
Get the status of a file or file descriptor by performing a :c:func:`!statx`
3389+
system call on the given path.
3390+
3391+
*path* is a :term:`path-like object` or an open file descriptor. *mask* is a
3392+
combination of the module-level :const:`STATX_* <STATX_TYPE>` constants
3393+
specifying the information to retrieve. *flags* is a combination of the
3394+
module-level :const:`AT_STATX_* <AT_STATX_FORCE_SYNC>` constants and/or
3395+
:const:`AT_NO_AUTOMOUNT`. Returns a :class:`statx_result` object whose
3396+
:attr:`~os.statx_result.stx_mask` attribute specifies the information
3397+
actually retrieved (which may differ from *mask*).
3398+
3399+
This function supports :ref:`specifying a file descriptor <path_fd>`,
3400+
:ref:`paths relative to directory descriptors <dir_fd>`, and
3401+
:ref:`not following symlinks <follow_symlinks>`.
3402+
3403+
.. seealso:: The :manpage:`statx(2)` man page.
3404+
3405+
.. availability:: Linux >= 4.11 with glibc >= 2.28.
3406+
3407+
.. versionadded:: next
3408+
3409+
3410+
.. class:: statx_result
3411+
3412+
Information about a file returned by :func:`os.statx`.
3413+
3414+
:class:`!statx_result` has all the attributes that :class:`~stat_result` has
3415+
on Linux, making it :term:`duck-typing` compatible, but
3416+
:class:`!statx_result` is not a subclass of :class:`~stat_result` and cannot
3417+
be used as a tuple.
3418+
3419+
:class:`!statx_result` has the following additional attributes:
3420+
3421+
.. attribute:: stx_mask
3422+
3423+
Bitmask of :const:`STATX_* <STATX_TYPE>` constants specifying the
3424+
information retrieved, which may differ from what was requested.
3425+
3426+
.. attribute:: stx_attributes_mask
3427+
3428+
Bitmask of :const:`STATX_ATTR_* <stat.STATX_ATTR_COMPRESSED>` constants
3429+
specifying the attributes bits supported for this file.
3430+
3431+
.. attribute:: stx_attributes
3432+
3433+
Bitmask of :const:`STATX_ATTR_* <stat.STATX_ATTR_COMPRESSED>` constants
3434+
specifying the attributes of this file.
3435+
3436+
.. attribute:: stx_dev_major
3437+
3438+
Major number of the device on which this file resides.
3439+
3440+
.. attribute:: stx_dev_minor
3441+
3442+
Minor number of the device on which this file resides.
3443+
3444+
.. attribute:: stx_rdev_major
3445+
3446+
Major number of the device this file represents.
3447+
3448+
.. attribute:: stx_rdev_minor
3449+
3450+
Minor number of the device this file represents.
3451+
3452+
.. attribute:: stx_mnt_id
3453+
3454+
Mount ID.
3455+
3456+
.. availability:: Linux >= 4.11 with glibc >= 2.28 and build-time kernel
3457+
userspace API headers >= 5.8.
3458+
3459+
.. attribute:: stx_dio_mem_align
3460+
3461+
Direct I/O memory buffer alignment requirement.
3462+
3463+
.. availability:: Linux >= 4.11 with glibc >= 2.28 and build-time kernel
3464+
userspace API headers >= 6.1.
3465+
3466+
.. attribute:: stx_dio_offset_align
3467+
3468+
Direct I/O file offset alignment requirement.
3469+
3470+
.. availability:: Linux >= 4.11 with glibc >= 2.28 and build-time kernel
3471+
userspace API headers >= 6.1.
3472+
3473+
.. attribute:: stx_subvol
3474+
3475+
Subvolume ID.
3476+
3477+
.. availability:: Linux >= 4.11 with glibc >= 2.28 and build-time kernel
3478+
userspace API headers >= 6.10.
3479+
3480+
.. attribute:: stx_atomic_write_unit_min
3481+
3482+
Minimum size for direct I/O with torn-write protection.
3483+
3484+
.. availability:: Linux >= 4.11 with glibc >= 2.28 and build-time kernel
3485+
userspace API headers >= 6.11.
3486+
3487+
.. attribute:: stx_atomic_write_unit_max
3488+
3489+
Maximum size for direct I/O with torn-write protection.
3490+
3491+
.. availability:: Linux >= 4.11 with glibc >= 2.28 and build-time kernel
3492+
userspace API headers >= 6.11.
3493+
3494+
.. attribute:: stx_atomic_write_unit_max_opt
3495+
3496+
Maximum optimized size for direct I/O with torn-write protection.
3497+
3498+
.. availability:: Linux >= 4.11 with glibc >= 2.28 and build-time kernel
3499+
userspace API headers >= 6.11.
3500+
3501+
.. attribute:: stx_atomic_write_segments_max
3502+
3503+
Maximum iovecs for direct I/O with torn-write protection.
3504+
3505+
.. availability:: Linux >= 4.11 with glibc >= 2.28 and build-time kernel
3506+
userspace API headers >= 6.11.
3507+
3508+
.. attribute:: stx_dio_read_offset_align
3509+
3510+
Direct I/O file offset alignment requirement for reads.
3511+
3512+
.. availability:: Linux >= 4.11 with glibc >= 2.28 and build-time kernel
3513+
userspace API headers >= 6.14.
3514+
3515+
.. seealso:: The :manpage:`statx(2)` man page.
3516+
3517+
.. availability:: Linux >= 4.11 with glibc >= 2.28.
3518+
3519+
.. versionadded:: next
3520+
3521+
3522+
.. data:: STATX_TYPE
3523+
STATX_MODE
3524+
STATX_NLINK
3525+
STATX_UID
3526+
STATX_GID
3527+
STATX_ATIME
3528+
STATX_MTIME
3529+
STATX_CTIME
3530+
STATX_INO
3531+
STATX_SIZE
3532+
STATX_BLOCKS
3533+
STATX_BASIC_STATS
3534+
STATX_BTIME
3535+
STATX_MNT_ID
3536+
STATX_DIOALIGN
3537+
STATX_MNT_ID_UNIQUE
3538+
STATX_SUBVOL
3539+
STATX_WRITE_ATOMIC
3540+
STATX_DIO_READ_ALIGN
3541+
3542+
Bitflags for use in the *mask* parameter to :func:`os.statx`. Flags
3543+
including and after :const:`!STATX_MNT_ID` are only available when their
3544+
corresponding members in :class:`statx_result` are available.
3545+
3546+
.. availability:: Linux >= 4.11 with glibc >= 2.28.
3547+
3548+
.. versionadded:: next
3549+
3550+
.. data:: AT_STATX_FORCE_SYNC
3551+
3552+
A flag for the :func:`os.statx` function. Requests that the kernel return
3553+
up-to-date information even when doing so is expensive (for example,
3554+
requiring a round trip to the server for a file on a network filesystem).
3555+
3556+
.. availability:: Linux >= 4.11 with glibc >= 2.28.
3557+
3558+
.. versionadded:: next
3559+
3560+
.. data:: AT_STATX_DONT_SYNC
3561+
3562+
A flag for the :func:`os.statx` function. Requests that the kernel return
3563+
cached information if possible.
3564+
3565+
.. availability:: Linux >= 4.11 with glibc >= 2.28.
3566+
3567+
.. versionadded:: next
3568+
3569+
.. data:: AT_STATX_SYNC_AS_STAT
3570+
3571+
A flag for the :func:`os.statx` function. This flag is defined as ``0``, so
3572+
it has no effect, but it can be used to explicitly indicate neither
3573+
:data:`AT_STATX_FORCE_SYNC` nor :data:`AT_STATX_DONT_SYNC` is being passed.
3574+
In the absence of the other two flags, the kernel will generally return
3575+
information as fresh as :func:`os.stat` would return.
3576+
3577+
.. availability:: Linux >= 4.11 with glibc >= 2.28.
3578+
3579+
.. versionadded:: next
3580+
3581+
3582+
.. data:: AT_NO_AUTOMOUNT
3583+
3584+
If the final component of a path is an automount point, operate on the
3585+
automount point instead of performing the automount. On Linux,
3586+
:func:`os.stat`, :func:`os.fstat` and :func:`os.lstat` always behave this
3587+
way.
3588+
3589+
.. availability:: Linux.
3590+
3591+
.. versionadded:: next
3592+
3593+
33863594
.. function:: statvfs(path)
33873595

33883596
Perform a :c:func:`!statvfs` system call on the given path. The return value is

Doc/library/stat.rst

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -493,3 +493,22 @@ constants, but are not an exhaustive list.
493493
IO_REPARSE_TAG_APPEXECLINK
494494

495495
.. versionadded:: 3.8
496+
497+
On Linux, the following file attribute constants are available for use when
498+
testing bits in the :attr:`~os.statx_result.stx_attributes` and
499+
:attr:`~os.statx_result.stx_attributes_mask` members returned by
500+
:func:`os.statx`. See the :manpage:`statx(2)` man page for more detail on the
501+
meaning of these constants.
502+
503+
.. data:: STATX_ATTR_COMPRESSED
504+
STATX_ATTR_IMMUTABLE
505+
STATX_ATTR_APPEND
506+
STATX_ATTR_NODUMP
507+
STATX_ATTR_ENCRYPTED
508+
STATX_ATTR_AUTOMOUNT
509+
STATX_ATTR_MOUNT_ROOT
510+
STATX_ATTR_VERITY
511+
STATX_ATTR_DAX
512+
STATX_ATTR_WRITE_ATOMIC
513+
514+
.. versionadded:: next

Doc/whatsnew/3.15.rst

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -433,6 +433,14 @@ mmap
433433
(Contributed by Serhiy Storchaka in :gh:`78502`.)
434434

435435

436+
os
437+
--
438+
439+
* Add :func:`os.statx` on Linux kernel versions 4.11 and later with
440+
glibc versions 2.28 and later.
441+
(Contributed by Jeffrey Bosboom in :gh:`83714`.)
442+
443+
436444
os.path
437445
-------
438446

@@ -828,8 +836,9 @@ New deprecations
828836
- :mod:`tabnanny`
829837
- :mod:`tkinter.font`
830838
- :mod:`tkinter.ttk`
839+
- :mod:`zlib`
831840

832-
(Contributed by Hugo van Kemenade in :gh:`76007`.)
841+
(Contributed by Hugo van Kemenade and Stan Ulbrych in :gh:`76007`.)
833842

834843
.. Add deprecations above alphabetically, not here at the end.
835844

Include/internal/pycore_global_objects_fini_generated.h

Lines changed: 1 addition & 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: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -590,6 +590,7 @@ struct _Py_global_strings {
590590
STRUCT_FOR_ID(loop)
591591
STRUCT_FOR_ID(manual_reset)
592592
STRUCT_FOR_ID(mapping)
593+
STRUCT_FOR_ID(mask)
593594
STRUCT_FOR_ID(match)
594595
STRUCT_FOR_ID(max_length)
595596
STRUCT_FOR_ID(maxdigits)

Include/internal/pycore_interp_structs.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -769,6 +769,12 @@ struct _is {
769769
* and should be placed at the beginning. */
770770
struct _ceval_state ceval;
771771

772+
/* This structure is carefully allocated so that it's correctly aligned
773+
* to avoid undefined behaviors during LOAD and STORE. The '_malloced'
774+
* field stores the allocated pointer address that will later be freed.
775+
*/
776+
void *_malloced;
777+
772778
PyInterpreterState *next;
773779

774780
int64_t id;

Include/internal/pycore_runtime_init_generated.h

Lines changed: 1 addition & 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: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)