diff options
author | Barry Warsaw <barry@python.org> | 2016-06-08 21:54:43 (GMT) |
---|---|---|
committer | Barry Warsaw <barry@python.org> | 2016-06-08 21:54:43 (GMT) |
commit | 118598a072be1ec8d6cbc3636cd514538a868152 (patch) | |
tree | f35b2737564ff02ecd3e9211ec9f27db550d9d45 /Modules/_io/fileio.c | |
parent | 24f3a1829fe007915a93e9515cd28470dd8a00d9 (diff) | |
parent | 480e28538d42b9cf8e8b2163bfa9e23e27b80793 (diff) | |
download | cpython-118598a072be1ec8d6cbc3636cd514538a868152.zip cpython-118598a072be1ec8d6cbc3636cd514538a868152.tar.gz cpython-118598a072be1ec8d6cbc3636cd514538a868152.tar.bz2 |
Issue #27066: Fixed SystemError if a custom opener (for open()) returns a
negative number without setting an exception.
Diffstat (limited to 'Modules/_io/fileio.c')
-rw-r--r-- | Modules/_io/fileio.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/Modules/_io/fileio.c b/Modules/_io/fileio.c index fe6bc41..12e5156 100644 --- a/Modules/_io/fileio.c +++ b/Modules/_io/fileio.c @@ -420,7 +420,13 @@ _io_FileIO___init___impl(fileio *self, PyObject *nameobj, const char *mode, self->fd = _PyLong_AsInt(fdobj); Py_DECREF(fdobj); - if (self->fd == -1) { + if (self->fd < 0) { + if (!PyErr_Occurred()) { + /* The opener returned a negative but didn't set an + exception. See issue #27066 */ + PyErr_Format(PyExc_ValueError, + "opener returned %d", self->fd); + } goto error; } } |