From: Gregory P. Smith Date: Wed, 24 May 2023 04:15:49 +0000 (-0700) Subject: gh-104372: use == -1 before PyErr_Occurred (#104831) X-Git-Tag: v3.13.0a1~2072 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=7f963bfc79a515dc9822ebddbfb1b5927d2dda09;p=thirdparty%2FPython%2Fcpython.git gh-104372: use == -1 before PyErr_Occurred (#104831) The ideal pattern for this. (already in the 3.11 backport) --- 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) {