[Python-checkins] [3.12] gh-104372: use == -1 before PyErr_Occurred (GH-104831) (#104833)

gpshead webhook-mailer at python.org
Wed May 24 00:40:38 EDT 2023


https://github.com/python/cpython/commit/b719dd8725a820a1af4b76c30ae87c23d8db68c0
commit: b719dd8725a820a1af4b76c30ae87c23d8db68c0
branch: 3.12
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: gpshead <greg at krypto.org>
date: 2023-05-24T04:40:21Z
summary:

[3.12] gh-104372: use == -1 before PyErr_Occurred (GH-104831) (#104833)

gh-104372: use == -1 before PyErr_Occurred (GH-104831)

The ideal pattern for this.  (already in the 3.11 backport)
(cherry picked from commit 7f963bfc79a515dc9822ebddbfb1b5927d2dda09)

Co-authored-by: Gregory P. Smith <greg at krypto.org>

files:
M Modules/_posixsubprocess.c

diff --git a/Modules/_posixsubprocess.c b/Modules/_posixsubprocess.c
index 1b7fe71186a1..63403795569a 100644
--- a/Modules/_posixsubprocess.c
+++ b/Modules/_posixsubprocess.c
@@ -200,7 +200,7 @@ convert_fds_to_keep_to_c(PyObject *py_fds_to_keep, int *c_fds_to_keep)
     for (i = 0; i < len; ++i) {
         PyObject* fdobj = PyTuple_GET_ITEM(py_fds_to_keep, i);
         long fd = PyLong_AsLong(fdobj);
-        if (PyErr_Occurred()) {
+        if (fd == -1 && PyErr_Occurred()) {
             return -1;
         }
         if (fd < 0 || fd > INT_MAX) {



More information about the Python-checkins mailing list