Issue #24402: Fix input() when stdout.fileno() fails; diagnosed by Eryksun

Also factored out some test cases into a new PtyTests class.
This commit is contained in:
Martin Panter 2015-10-10 01:25:38 +00:00
parent ff1f3d9ff1
commit c9a6ab56cf
3 changed files with 116 additions and 77 deletions

View file

@ -1723,8 +1723,10 @@ builtin_input(PyObject *self, PyObject *args)
}
if (tty) {
tmp = _PyObject_CallMethodId(fout, &PyId_fileno, "");
if (tmp == NULL)
if (tmp == NULL) {
PyErr_Clear();
tty = 0;
}
else {
fd = PyLong_AsLong(tmp);
Py_DECREF(tmp);