diff options
author | Barry Warsaw <barry@python.org> | 2016-06-08 21:47:26 (GMT) |
---|---|---|
committer | Barry Warsaw <barry@python.org> | 2016-06-08 21:47:26 (GMT) |
commit | 480e28538d42b9cf8e8b2163bfa9e23e27b80793 (patch) | |
tree | bd028ce2b5a97755fc3aec27208fc0b2067ebe1a /Modules | |
parent | fda4d67842a406d2fa285f929ddf890c2393e1c2 (diff) | |
download | cpython-480e28538d42b9cf8e8b2163bfa9e23e27b80793.zip cpython-480e28538d42b9cf8e8b2163bfa9e23e27b80793.tar.gz cpython-480e28538d42b9cf8e8b2163bfa9e23e27b80793.tar.bz2 |
Issue #27066: Fixed SystemError if a custom opener (for open()) returns
a negative number without setting an exception.
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/_io/fileio.c | 7 |
1 files changed, 6 insertions, 1 deletions
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 @@ _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 -1. See issue #27066 */ + PyErr_Format(PyExc_ValueError, + "opener returned %d", self->fd); + } goto error; } } |