mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +00:00
Issue #27066: Fixed SystemError if a custom opener (for open()) returns
a negative number without setting an exception.
This commit is contained in:
parent
fda4d67842
commit
480e28538d
3 changed files with 25 additions and 1 deletions
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue