[Python-checkins] bpo-41687: Fix error handling in Solaris sendfile implementation (GH-22128)

Miss Islington (bot) webhook-mailer at python.org
Wed Sep 16 08:25:17 EDT 2020

commit: 6a39888c2c4bcfbcdc61a1953911ad30c62da1ef
branch: 3.9
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: GitHub <noreply at github.com>
date: 2020-09-16T05:25:09-07:00

bpo-41687: Fix error handling in Solaris sendfile implementation (GH-22128)

I just realized that my recent PR with sendfile on Solaris ([PR 22040](https://github.com/python/cpython/pull/22040)) has broken error handling.

Sorry for that, this simple followup fixes that.

Automerge-Triggered-By: @1st1
(cherry picked from commit fa8c9e70104b0aef966a518eb3a80a4881906ae0)

Co-authored-by: Jakub Kulík <Kulikjak at gmail.com>

M Modules/posixmodule.c

diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
index 39f5f577a8286..01e8bcbd2981a 100644
--- a/Modules/posixmodule.c
+++ b/Modules/posixmodule.c
@@ -9456,14 +9456,13 @@ os_sendfile_impl(PyObject *module, int out_fd, int in_fd, PyObject *offobj,
 #if defined(__sun) && defined(__SVR4)
     // On Solaris, sendfile raises EINVAL rather than returning 0
     // when the offset is equal or bigger than the in_fd size.
-    int res;
     struct stat st;
     do {
-        res = fstat(in_fd, &st);
+        ret = fstat(in_fd, &st);
-    } while (res != 0 && errno == EINTR && !(async_err = PyErr_CheckSignals()));
+    } while (ret != 0 && errno == EINTR && !(async_err = PyErr_CheckSignals()));
     if (ret < 0)
         return (!async_err) ? posix_error() : NULL;

More information about the Python-checkins mailing list