From 56a064288b7341395c84affc53255624887090b6 Mon Sep 17 00:00:00 2001 From: YoSTEALTH <35307184+YoSTEALTH@users.noreply.github.com> Date: Sat, 23 May 2020 15:07:06 -0600 Subject: [PATCH 1/7] added `RWF_APPEND` --- Modules/posixmodule.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c index ddff28354a7c17..59523015338c0e 100644 --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -9778,6 +9778,7 @@ The flags argument contains a bitwise OR of zero or more of the following flags: - RWF_DSYNC - RWF_SYNC +- RWF_APPEND Using non-zero flags requires Linux 4.7 or newer. [clinic start generated code]*/ @@ -14514,6 +14515,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 /* constants for posix_spawn */ #ifdef HAVE_POSIX_SPAWN From 0e247c0a63c7186bc6702ddb747c15a749a38af3 Mon Sep 17 00:00:00 2001 From: YoSTEALTH Date: Sat, 23 May 2020 16:23:07 -0600 Subject: [PATCH 2/7] added new `os.RWF_APPEND` flag for `os.pwritev` --- Doc/library/os.rst | 10 ++++++++++ .../Library/2020-05-23-4-18-00.bpo-37129.YoYoYo.rst | 1 + Modules/clinic/posixmodule.c.h | 3 ++- Modules/posixmodule.c | 2 +- 4 files changed, 14 insertions(+), 2 deletions(-) create mode 100644 Misc/NEWS.d/next/Library/2020-05-23-4-18-00.bpo-37129.YoYoYo.rst diff --git a/Doc/library/os.rst b/Doc/library/os.rst index 6d5fb314a8e39a..f9e1d6cd601843 100644 --- a/Doc/library/os.rst +++ b/Doc/library/os.rst @@ -1211,6 +1211,7 @@ or `the MSDN `_ on Windo - :data:`RWF_DSYNC` - :data:`RWF_SYNC` + - :data:`RWF_APPEND` Return the total number of bytes actually written. @@ -1246,6 +1247,15 @@ or `the MSDN `_ on Windo .. versionadded:: 3.7 +.. data:: RWF_APPEND + + Provide a per-write equivalent of the :data:`O_APPEND` :func:``os.open()`` flag. This flag is meaningful only for :func:``os.pwritev()``, 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. + + .. availability:: Linux 4.16 and newer. + + .. versionadded:: 3.10 + + .. function:: read(fd, n) Read at most *n* bytes from file descriptor *fd*. diff --git a/Misc/NEWS.d/next/Library/2020-05-23-4-18-00.bpo-37129.YoYoYo.rst b/Misc/NEWS.d/next/Library/2020-05-23-4-18-00.bpo-37129.YoYoYo.rst new file mode 100644 index 00000000000000..e025e96f4f1c05 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2020-05-23-4-18-00.bpo-37129.YoYoYo.rst @@ -0,0 +1 @@ +Add a new :data:`os.RWF_APPEND` flag for :func:`os.pwritev`. diff --git a/Modules/clinic/posixmodule.c.h b/Modules/clinic/posixmodule.c.h index 41baa455739797..4e143c2b8dc756 100644 --- a/Modules/clinic/posixmodule.c.h +++ b/Modules/clinic/posixmodule.c.h @@ -5852,6 +5852,7 @@ PyDoc_STRVAR(os_pwritev__doc__, "\n" "- RWF_DSYNC\n" "- RWF_SYNC\n" +"- RWF_APPEND\n" "\n" "Using non-zero flags requires Linux 4.7 or newer."); @@ -9396,4 +9397,4 @@ os_waitstatus_to_exitcode(PyObject *module, PyObject *const *args, Py_ssize_t na #ifndef OS_WAITSTATUS_TO_EXITCODE_METHODDEF #define OS_WAITSTATUS_TO_EXITCODE_METHODDEF #endif /* !defined(OS_WAITSTATUS_TO_EXITCODE_METHODDEF) */ -/*[clinic end generated code: output=005919eaaef3f8e6 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=1c56432c243f1ea4 input=a9049054013a1b77]*/ diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c index 59523015338c0e..c33b532b570b02 100644 --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -9786,7 +9786,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=803dc5ddbf0cfd3b]*/ +/*[clinic end generated code: output=e3dd3e9d11a6a5c7 input=35358c327e1a2a8e]*/ { Py_ssize_t cnt; Py_ssize_t result; From 0e443f7aa06ddbee3854f492b3ef81fcc151b7ee Mon Sep 17 00:00:00 2001 From: YoSTEALTH Date: Sat, 23 May 2020 16:37:19 -0600 Subject: [PATCH 3/7] fixed incorrect date format --- ...-37129.YoYoYo.rst => 2020-05-23-04-18-00.bpo-37129.YoYoYo.rst} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename Misc/NEWS.d/next/Library/{2020-05-23-4-18-00.bpo-37129.YoYoYo.rst => 2020-05-23-04-18-00.bpo-37129.YoYoYo.rst} (100%) diff --git a/Misc/NEWS.d/next/Library/2020-05-23-4-18-00.bpo-37129.YoYoYo.rst b/Misc/NEWS.d/next/Library/2020-05-23-04-18-00.bpo-37129.YoYoYo.rst similarity index 100% rename from Misc/NEWS.d/next/Library/2020-05-23-4-18-00.bpo-37129.YoYoYo.rst rename to Misc/NEWS.d/next/Library/2020-05-23-04-18-00.bpo-37129.YoYoYo.rst From b03b79da82e4f858f1ef36cbc802d0013c965d13 Mon Sep 17 00:00:00 2001 From: YoSTEALTH Date: Sat, 23 May 2020 18:07:48 -0600 Subject: [PATCH 4/7] limited line characters --- Doc/library/os.rst | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Doc/library/os.rst b/Doc/library/os.rst index f9e1d6cd601843..7046474d229b37 100644 --- a/Doc/library/os.rst +++ b/Doc/library/os.rst @@ -1249,7 +1249,12 @@ or `the MSDN `_ on Windo .. data:: RWF_APPEND - Provide a per-write equivalent of the :data:`O_APPEND` :func:``os.open()`` flag. This flag is meaningful only for :func:``os.pwritev()``, 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. + Provide a per-write equivalent of the :data:`O_APPEND` :func:``os.open()`` + flag. This flag is meaningful only for :func:``os.pwritev()``, 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. .. availability:: Linux 4.16 and newer. From 75d9bcbe7ce173218b1866ab27f89611b0c914f4 Mon Sep 17 00:00:00 2001 From: YoSTEALTH Date: Sat, 23 May 2020 18:37:25 -0600 Subject: [PATCH 5/7] removed typo `()` --- Doc/library/os.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Doc/library/os.rst b/Doc/library/os.rst index 7046474d229b37..ac71400fab6dda 100644 --- a/Doc/library/os.rst +++ b/Doc/library/os.rst @@ -1249,8 +1249,8 @@ or `the MSDN `_ on Windo .. data:: RWF_APPEND - Provide a per-write equivalent of the :data:`O_APPEND` :func:``os.open()`` - flag. This flag is meaningful only for :func:``os.pwritev()``, and its + Provide a per-write equivalent of the :data:`O_APPEND` :func:``os.open`` + flag. This flag is meaningful only for :func:``os.pwritev``, 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 From 72555e3da42486ef1c9374792e2962ff0c3f80b4 Mon Sep 17 00:00:00 2001 From: YoSTEALTH Date: Sat, 23 May 2020 18:56:10 -0600 Subject: [PATCH 6/7] fixed :func: to single `, also added :func: to RWF_DSYNC, RWF_SYNC open --- Doc/library/os.rst | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Doc/library/os.rst b/Doc/library/os.rst index ac71400fab6dda..275b2d390e7cf5 100644 --- a/Doc/library/os.rst +++ b/Doc/library/os.rst @@ -1229,8 +1229,8 @@ or `the MSDN `_ on Windo .. data:: RWF_DSYNC - Provide a per-write equivalent of the :data:`O_DSYNC` ``open(2)`` flag. This - flag effect applies only to the data range written by the system call. + Provide a per-write equivalent of the :data:`O_DSYNC` :func:`os.open` flag. + This flag effect applies only to the data range written by the system call. .. availability:: Linux 4.7 and newer. @@ -1239,8 +1239,8 @@ or `the MSDN `_ on Windo .. data:: RWF_SYNC - Provide a per-write equivalent of the :data:`O_SYNC` ``open(2)`` flag. This - flag effect applies only to the data range written by the system call. + Provide a per-write equivalent of the :data:`O_SYNC` :func:`os.open` flag. + This flag effect applies only to the data range written by the system call. .. availability:: Linux 4.7 and newer. @@ -1249,8 +1249,8 @@ or `the MSDN `_ on Windo .. data:: RWF_APPEND - Provide a per-write equivalent of the :data:`O_APPEND` :func:``os.open`` - flag. This flag is meaningful only for :func:``os.pwritev``, and its + Provide a per-write equivalent of the :data:`O_APPEND` :func:`os.open` + flag. This flag is meaningful only for :func:`os.pwritev`, 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 From 538d18456fce52a428b8a8ee02dad7afafafb55a Mon Sep 17 00:00:00 2001 From: YoSTEALTH Date: Wed, 27 May 2020 14:52:34 -0600 Subject: [PATCH 7/7] updated clinic generated code --- Modules/clinic/posixmodule.c.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/clinic/posixmodule.c.h b/Modules/clinic/posixmodule.c.h index 7cb58f449c80dd..96ea02035ea419 100644 --- a/Modules/clinic/posixmodule.c.h +++ b/Modules/clinic/posixmodule.c.h @@ -8877,4 +8877,4 @@ os_waitstatus_to_exitcode(PyObject *module, PyObject *const *args, Py_ssize_t na #ifndef OS_WAITSTATUS_TO_EXITCODE_METHODDEF #define OS_WAITSTATUS_TO_EXITCODE_METHODDEF #endif /* !defined(OS_WAITSTATUS_TO_EXITCODE_METHODDEF) */ -/*[clinic end generated code: output=1c56432c243f1ea4 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=9623b9e6f3809842 input=a9049054013a1b77]*/