Message244957
This looks like an oversight. In the implementation in [bltinmodule.c][1], if checking sys.stdout.fileno() fails, it clears the error without setting tty = 0. It's the [same in 3.5][2].
/* We should only use (GNU) readline if Python's sys.stdin and
sys.stdout are the same as C's stdin and stdout, because we
need to pass it those. */
tmp = _PyObject_CallMethodId(fin, &PyId_fileno, "");
if (tmp == NULL) {
PyErr_Clear();
tty = 0;
}
else {
fd = PyLong_AsLong(tmp);
Py_DECREF(tmp);
if (fd < 0 && PyErr_Occurred())
return NULL;
tty = fd == fileno(stdin) && isatty(fd);
}
if (tty) {
tmp = _PyObject_CallMethodId(fout, &PyId_fileno, "");
if (tmp == NULL)
PyErr_Clear();
else {
fd = PyLong_AsLong(tmp);
Py_DECREF(tmp);
if (fd < 0 && PyErr_Occurred())
return NULL;
tty = fd == fileno(stdout) && isatty(fd);
}
}
[1]: https://hg.python.org/cpython/file/b4cbecbc0781/Python/bltinmodule.c#l1709
[2]: https://hg.python.org/cpython/file/7a088af5615b/Python/bltinmodule.c#l1839 |
|
Date |
User |
Action |
Args |
2015-06-07 13:59:15 | eryksun | set | recipients:
+ eryksun, Keita Kita |
2015-06-07 13:59:15 | eryksun | set | messageid: <1433685555.5.0.170701389531.issue24402@psf.upfronthosting.co.za> |
2015-06-07 13:59:15 | eryksun | link | issue24402 messages |
2015-06-07 13:59:15 | eryksun | create | |
|