This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author eryksun
Recipients Keita Kita, eryksun
Date 2015-06-07.13:59:15
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1433685555.5.0.170701389531.issue24402@psf.upfronthosting.co.za>
In-reply-to
Content
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
History
Date User Action Args
2015-06-07 13:59:15eryksunsetrecipients: + eryksun, Keita Kita
2015-06-07 13:59:15eryksunsetmessageid: <1433685555.5.0.170701389531.issue24402@psf.upfronthosting.co.za>
2015-06-07 13:59:15eryksunlinkissue24402 messages
2015-06-07 13:59:15eryksuncreate