]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-104372: use == -1 before PyErr_Occurred (#104831)
authorGregory P. Smith <greg@krypto.org>
Wed, 24 May 2023 04:15:49 +0000 (21:15 -0700)
committerGitHub <noreply@github.com>
Wed, 24 May 2023 04:15:49 +0000 (04:15 +0000)
The ideal pattern for this.  (already in the 3.11 backport)

Modules/_posixsubprocess.c

index 1b7fe71186a1635221ca9e344dd5788c22dca302..63403795569a78c8f32f9f24bc61ce149f3e397b 100644 (file)
@@ -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) {