From: Clay Dugo Date: Tue, 6 Jan 2026 14:35:51 +0000 (-0500) Subject: gh-143474: Add `os.RWF_ATOMIC` constant (GH-143475) X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d745b60ef234228beea30e8d182358f29ffb1cb4;p=thirdparty%2FPython%2Fcpython.git gh-143474: Add `os.RWF_ATOMIC` constant (GH-143475) --- diff --git a/Doc/library/os.rst b/Doc/library/os.rst index f75ad4e67a66..9a9b79e7906c 100644 --- a/Doc/library/os.rst +++ b/Doc/library/os.rst @@ -1556,6 +1556,15 @@ or `the MSDN `_ on Windo .. versionadded:: 3.15 +.. data:: RWF_ATOMIC + + Write data atomically. Requires alignment to the device's atomic write unit. + + .. availability:: Linux >= 6.11 + + .. versionadded:: next + + .. function:: ptsname(fd, /) Return the name of the slave pseudo-terminal device associated with the @@ -1598,6 +1607,7 @@ or `the MSDN `_ on Windo - :data:`RWF_SYNC` - :data:`RWF_APPEND` - :data:`RWF_DONTCACHE` + - :data:`RWF_ATOMIC` Return the total number of bytes actually written. diff --git a/Misc/NEWS.d/next/Library/2026-01-06-12-00-00.gh-issue-143474.cQM4VA.rst b/Misc/NEWS.d/next/Library/2026-01-06-12-00-00.gh-issue-143474.cQM4VA.rst new file mode 100644 index 000000000000..b3aa69f80aa9 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2026-01-06-12-00-00.gh-issue-143474.cQM4VA.rst @@ -0,0 +1 @@ +Add :data:`os.RWF_ATOMIC` constant for Linux 6.11+. diff --git a/Modules/clinic/posixmodule.c.h b/Modules/clinic/posixmodule.c.h index d880fc52bb37..03c0f221ba98 100644 --- a/Modules/clinic/posixmodule.c.h +++ b/Modules/clinic/posixmodule.c.h @@ -8692,6 +8692,7 @@ PyDoc_STRVAR(os_pwritev__doc__, "- RWF_SYNC\n" "- RWF_APPEND\n" "- RWF_DONTCACHE\n" +"- RWF_ATOMIC\n" "\n" "Using non-zero flags requires Linux 4.7 or newer."); @@ -13610,4 +13611,4 @@ exit: #ifndef OS__EMSCRIPTEN_LOG_METHODDEF #define OS__EMSCRIPTEN_LOG_METHODDEF #endif /* !defined(OS__EMSCRIPTEN_LOG_METHODDEF) */ -/*[clinic end generated code: output=82f60940338c70e4 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=5fd2aeb6ba9a5df8 input=a9049054013a1b77]*/ diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c index b26785abc3cd..49214d57a2e3 100644 --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -12863,6 +12863,7 @@ The flags argument contains a bitwise OR of zero or more of the following flags: - RWF_SYNC - RWF_APPEND - RWF_DONTCACHE +- RWF_ATOMIC Using non-zero flags requires Linux 4.7 or newer. [clinic start generated code]*/ @@ -12870,7 +12871,7 @@ Using non-zero flags requires Linux 4.7 or newer. static Py_ssize_t os_pwritev_impl(PyObject *module, int fd, PyObject *buffers, Py_off_t offset, int flags) -/*[clinic end generated code: output=e3dd3e9d11a6a5c7 input=664a67626d485665]*/ +/*[clinic end generated code: output=e3dd3e9d11a6a5c7 input=7de72245873f56bf]*/ { Py_ssize_t cnt; Py_ssize_t result; @@ -18120,6 +18121,9 @@ all_ins(PyObject *m) #ifdef RWF_DONTCACHE if (PyModule_AddIntConstant(m, "RWF_DONTCACHE", RWF_DONTCACHE)) return -1; #endif +#ifdef RWF_ATOMIC + if (PyModule_AddIntConstant(m, "RWF_ATOMIC", RWF_ATOMIC)) return -1; +#endif #ifdef RWF_APPEND if (PyModule_AddIntConstant(m, "RWF_APPEND", RWF_APPEND)) return -1; #endif