]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-143474: Add `os.RWF_ATOMIC` constant (GH-143475)
authorClay Dugo <claydugo@gmail.com>
Tue, 6 Jan 2026 14:35:51 +0000 (09:35 -0500)
committerGitHub <noreply@github.com>
Tue, 6 Jan 2026 14:35:51 +0000 (09:35 -0500)
Doc/library/os.rst
Misc/NEWS.d/next/Library/2026-01-06-12-00-00.gh-issue-143474.cQM4VA.rst [new file with mode: 0644]
Modules/clinic/posixmodule.c.h
Modules/posixmodule.c

index f75ad4e67a66d7a7775ecc5e641d7f20f7fc45d1..9a9b79e7906cc3d1cfa51b2adc165da529b76e9d 100644 (file)
@@ -1556,6 +1556,15 @@ or `the MSDN <https://msdn.microsoft.com/en-us/library/z0kc8e3z.aspx>`_ 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 <https://msdn.microsoft.com/en-us/library/z0kc8e3z.aspx>`_ 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 (file)
index 0000000..b3aa69f
--- /dev/null
@@ -0,0 +1 @@
+Add :data:`os.RWF_ATOMIC` constant for Linux 6.11+.
index d880fc52bb370dc786c3b14ce9ea562d379f9771..03c0f221ba98b34219bcfb1b5b59da0d245f9cbe 100644 (file)
@@ -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]*/
index b26785abc3cd27732b980810a2ddc75bd0286720..49214d57a2e362aa30d6c340767936e8bee3cbcc 100644 (file)
@@ -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