Return None rather than raise an exception if os.device_error is given an invalid file descriptor.
This commit is contained in:
Kristján Valur Jónsson 2009-03-24 14:15:49 +00:00
parent 8915e0e43a
commit 649170bd66
1 changed files with 1 additions and 3 deletions

View File

@ -6830,9 +6830,7 @@ device_encoding(PyObject *self, PyObject *args)
int fd; int fd;
if (!PyArg_ParseTuple(args, "i:device_encoding", &fd)) if (!PyArg_ParseTuple(args, "i:device_encoding", &fd))
return NULL; return NULL;
if (!_PyVerify_fd(fd)) if (!_PyVerify_fd(fd) || !isatty(fd)) {
return posix_error();
if (!isatty(fd)) {
Py_INCREF(Py_None); Py_INCREF(Py_None);
return Py_None; return Py_None;
} }