From 27e7bb66a7bac4355873b5094306237afd6e9793 Mon Sep 17 00:00:00 2001 From: RUANG Date: Fri, 13 Dec 2024 21:55:26 +0800 Subject: [PATCH 1/2] Add RWF_ATOMIC constant to os module --- Doc/library/os.rst | 27 +++++++++++++++++-- ...-12-13-21-55-13.gh-issue-127921.ESmy45.rst | 1 + Modules/posixmodule.c | 3 +++ 3 files changed, 29 insertions(+), 2 deletions(-) create mode 100644 Misc/NEWS.d/next/Library/2024-12-13-21-55-13.gh-issue-127921.ESmy45.rst diff --git a/Doc/library/os.rst b/Doc/library/os.rst index dfe5ef0726ff7d..bed244430408d7 100644 --- a/Doc/library/os.rst +++ b/Doc/library/os.rst @@ -1589,6 +1589,7 @@ or `the MSDN `_ on Windo - :data:`RWF_DSYNC` - :data:`RWF_SYNC` - :data:`RWF_APPEND` + - :data:`RWF_ATOMIC` Return the total number of bytes actually written. @@ -1638,6 +1639,16 @@ or `the MSDN `_ on Windo .. versionadded:: 3.10 +.. data:: RWF_ATOMIC + + Ensure the atomicity of :func:`os.pwritev` write operation. The behavior of + :data:`RWF_ATOMIC` will not take effect on unsupported hardware or file systems. + + .. availability:: Linux >= 6.11. + + .. versionadded:: next + + .. function:: read(fd, n, /) Read at most *n* bytes from file descriptor *fd*. @@ -5732,8 +5743,8 @@ Random numbers ``/dev/urandom`` devices. The flags argument is a bit mask that can contain zero or more of the - following values ORed together: :py:const:`os.GRND_RANDOM` and - :py:data:`GRND_NONBLOCK`. + following values ORed together: :py:const:`os.GRND_RANDOM`, + :py:data:`GRND_NONBLOCK` and :py:data:`GRND_INSECURE`. See also the `Linux getrandom() manual page `_. @@ -5803,3 +5814,15 @@ Random numbers ``/dev/random`` pool instead of the ``/dev/urandom`` pool. .. versionadded:: 3.6 + +.. data:: GRND_INSECURE + + If this flag is set, then :func:`getrandom` will return pseudo-random data + even if the entropy pool has not yet been initialized. + (It cannot be used with :py:const:`os.GRND_RANDOM`.) + + .. note:: + + It is not suitable for scenarios requiring secure cryptography. + + .. versionadded:: next diff --git a/Misc/NEWS.d/next/Library/2024-12-13-21-55-13.gh-issue-127921.ESmy45.rst b/Misc/NEWS.d/next/Library/2024-12-13-21-55-13.gh-issue-127921.ESmy45.rst new file mode 100644 index 00000000000000..4bf0a71cb094b7 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2024-12-13-21-55-13.gh-issue-127921.ESmy45.rst @@ -0,0 +1 @@ +Add the :data:`~os.RWF_ATOMIC` constant to the :mod:`os` module. diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c index 6eb7054b566e3f..6b0393b81794f3 100644 --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -17468,6 +17468,9 @@ all_ins(PyObject *m) #ifdef RWF_APPEND if (PyModule_AddIntConstant(m, "RWF_APPEND", RWF_APPEND)) return -1; #endif +#ifdef RWF_ATOMIC + if (PyModule_AddIntConstant(m, "RWF_ATOMIC", RWF_ATOMIC)) return -1; +#endif /* constants for splice */ #if defined(HAVE_SPLICE) && defined(__linux__) From 981795db074732953c59e3bd9ca8857e841db35e Mon Sep 17 00:00:00 2001 From: RUANG Date: Fri, 13 Dec 2024 21:58:25 +0800 Subject: [PATCH 2/2] Remove other changes --- Doc/library/os.rst | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/Doc/library/os.rst b/Doc/library/os.rst index bed244430408d7..e1da9e5d70aaf0 100644 --- a/Doc/library/os.rst +++ b/Doc/library/os.rst @@ -5743,8 +5743,8 @@ Random numbers ``/dev/urandom`` devices. The flags argument is a bit mask that can contain zero or more of the - following values ORed together: :py:const:`os.GRND_RANDOM`, - :py:data:`GRND_NONBLOCK` and :py:data:`GRND_INSECURE`. + following values ORed together: :py:const:`os.GRND_RANDOM` and + :py:data:`GRND_NONBLOCK`. See also the `Linux getrandom() manual page `_. @@ -5814,15 +5814,3 @@ Random numbers ``/dev/random`` pool instead of the ``/dev/urandom`` pool. .. versionadded:: 3.6 - -.. data:: GRND_INSECURE - - If this flag is set, then :func:`getrandom` will return pseudo-random data - even if the entropy pool has not yet been initialized. - (It cannot be used with :py:const:`os.GRND_RANDOM`.) - - .. note:: - - It is not suitable for scenarios requiring secure cryptography. - - .. versionadded:: next pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy