Issue #27066: Fixed SystemError if a custom opener (for open()) returns
a negative number without setting an exception.
diff --git a/Modules/_io/fileio.c b/Modules/_io/fileio.c
index 83b6a32..3d41d81 100644
--- a/Modules/_io/fileio.c
+++ b/Modules/_io/fileio.c
@@ -421,7 +421,12 @@
 
             self->fd = _PyLong_AsInt(fdobj);
             Py_DECREF(fdobj);
-            if (self->fd == -1) {
+            if (self->fd < 0) {
+                if (!PyErr_Occurred()) {
+                    /* The opener returned -1.  See issue #27066 */
+                    PyErr_Format(PyExc_ValueError,
+                                 "opener returned %d", self->fd);
+                }
                 goto error;
             }
         }