Skip to content

bpo-37129: Add os.RWF_APPEND flag for os.pwritev #13735

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions Doc/library/os.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1196,6 +1196,7 @@ or `the MSDN <https://msdn.microsoft.com/en-us/library/z0kc8e3z.aspx>`_ on Windo

- :data:`RWF_DSYNC`
- :data:`RWF_SYNC`
- :data:`RWF_APPEND`

Return the total number of bytes actually written.

Expand Down Expand Up @@ -1230,6 +1231,16 @@ or `the MSDN <https://msdn.microsoft.com/en-us/library/z0kc8e3z.aspx>`_ on Windo
.. versionadded:: 3.7


.. data:: RWF_APPEND

Append data to the end of the file. See the description of the flag 'O_APPEND' in ''os.open()''.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry "Provide a per-write equivalent of the O_APPEND in os.open(). This flag effect applies only to the data range written by the system call. The offset argument does not affect the write operation; the data is always appended to the end of the file. However, if the offset argument is -1, the current file offset is updated." I am sure vstinner will want to change this description again :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'O_APPEND' should be written :data:O_APPEND.

''os.open()'' should be written :func:os.open to add a link.

But os.open() doesn't document O_APPEND, just "The above constants are available on Unix and Windows"...

I would prefer to copy preadv Linux manual page:

       RWF_APPEND (since Linux 4.16)
              Provide a per-write equivalent of  the  O_APPEND  open(2)  flag.
              This  flag  is  meaningful  only  for pwritev2(), and its effect
              applies only to the data range written by the system call.   The
              offset argument does not affect the write operation; the data is
              always appended to the end of the file.  However, if the  offset
              argument is -1, the current file offset is updated.

(Adapt it to Python names.)

The *offset* field is ignored. The file *offset* is not changed.

.. availability:: Linux 4.16 and newer.

.. versionadded:: 3.8
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
.. versionadded:: 3.8
.. versionadded:: 3.9



.. function:: read(fd, n)

Read at most *n* bytes from file descriptor *fd*.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
add RWF_APPEND flag
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest:

Add a new :data:`os.RWF_APPEND` flag for :func:`os.pwritev`.

1 change: 1 addition & 0 deletions Modules/clinic/posixmodule.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Modules/posixmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -14023,6 +14023,9 @@ all_ins(PyObject *m)
#ifdef RWF_NOWAIT
if (PyModule_AddIntConstant(m, "RWF_NOWAIT", RWF_NOWAIT)) return -1;
#endif
#ifdef RWF_APPEND
if (PyModule_AddIntConstant(m, "RWF_APPEND", RWF_APPEND)) return -1;
#endif

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to add - RWF_APPEND on line: 9396

/* constants for posix_spawn */
#ifdef HAVE_POSIX_SPAWN
Expand Down