Skip to content

Commit 76ef255

Browse files
authored
bpo-37129: Add os.RWF_APPEND flag for os.pwritev() (GH-20336)
1 parent e4799b9 commit 76ef255

File tree

4 files changed

+27
-6
lines changed

4 files changed

+27
-6
lines changed

Doc/library/os.rst

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1211,6 +1211,7 @@ or `the MSDN <https://msdn.microsoft.com/en-us/library/z0kc8e3z.aspx>`_ on Windo
12111211

12121212
- :data:`RWF_DSYNC`
12131213
- :data:`RWF_SYNC`
1214+
- :data:`RWF_APPEND`
12141215

12151216
Return the total number of bytes actually written.
12161217

@@ -1228,8 +1229,8 @@ or `the MSDN <https://msdn.microsoft.com/en-us/library/z0kc8e3z.aspx>`_ on Windo
12281229

12291230
.. data:: RWF_DSYNC
12301231

1231-
Provide a per-write equivalent of the :data:`O_DSYNC` ``open(2)`` flag. This
1232-
flag effect applies only to the data range written by the system call.
1232+
Provide a per-write equivalent of the :data:`O_DSYNC` :func:`os.open` flag.
1233+
This flag effect applies only to the data range written by the system call.
12331234

12341235
.. availability:: Linux 4.7 and newer.
12351236

@@ -1238,14 +1239,28 @@ or `the MSDN <https://msdn.microsoft.com/en-us/library/z0kc8e3z.aspx>`_ on Windo
12381239

12391240
.. data:: RWF_SYNC
12401241

1241-
Provide a per-write equivalent of the :data:`O_SYNC` ``open(2)`` flag. This
1242-
flag effect applies only to the data range written by the system call.
1242+
Provide a per-write equivalent of the :data:`O_SYNC` :func:`os.open` flag.
1243+
This flag effect applies only to the data range written by the system call.
12431244

12441245
.. availability:: Linux 4.7 and newer.
12451246

12461247
.. versionadded:: 3.7
12471248

12481249

1250+
.. data:: RWF_APPEND
1251+
1252+
Provide a per-write equivalent of the :data:`O_APPEND` :func:`os.open`
1253+
flag. This flag is meaningful only for :func:`os.pwritev`, and its
1254+
effect applies only to the data range written by the system call. The
1255+
*offset* argument does not affect the write operation; the data is always
1256+
appended to the end of the file. However, if the *offset* argument is
1257+
``-1``, the current file *offset* is updated.
1258+
1259+
.. availability:: Linux 4.16 and newer.
1260+
1261+
.. versionadded:: 3.10
1262+
1263+
12491264
.. function:: read(fd, n)
12501265

12511266
Read at most *n* bytes from file descriptor *fd*.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Add a new :data:`os.RWF_APPEND` flag for :func:`os.pwritev`.

Modules/clinic/posixmodule.c.h

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Modules/posixmodule.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9778,14 +9778,15 @@ The flags argument contains a bitwise OR of zero or more of the following flags:
97789778
97799779
- RWF_DSYNC
97809780
- RWF_SYNC
9781+
- RWF_APPEND
97819782
97829783
Using non-zero flags requires Linux 4.7 or newer.
97839784
[clinic start generated code]*/
97849785

97859786
static Py_ssize_t
97869787
os_pwritev_impl(PyObject *module, int fd, PyObject *buffers, Py_off_t offset,
97879788
int flags)
9788-
/*[clinic end generated code: output=e3dd3e9d11a6a5c7 input=803dc5ddbf0cfd3b]*/
9789+
/*[clinic end generated code: output=e3dd3e9d11a6a5c7 input=35358c327e1a2a8e]*/
97899790
{
97909791
Py_ssize_t cnt;
97919792
Py_ssize_t result;
@@ -14509,6 +14510,9 @@ all_ins(PyObject *m)
1450914510
#ifdef RWF_NOWAIT
1451014511
if (PyModule_AddIntConstant(m, "RWF_NOWAIT", RWF_NOWAIT)) return -1;
1451114512
#endif
14513+
#ifdef RWF_APPEND
14514+
if (PyModule_AddIntConstant(m, "RWF_APPEND", RWF_APPEND)) return -1;
14515+
#endif
1451214516

1451314517
/* constants for posix_spawn */
1451414518
#ifdef HAVE_POSIX_SPAWN

0 commit comments

Comments
 (0)