Message321281
_iomodule.c:_io_open_impl checks for isatty even if not necessary (when buffering >= 0).
Code: https://github.com/python/cpython/blob/c0ee341b29bd7d978b49272a2c0e2dcfa77404d5/Modules/_io/_iomodule.c#L392
{
PyObject *res = _PyObject_CallMethodId(raw, &PyId_isatty, NULL);
if (res == NULL)
goto error;
isatty = PyLong_AsLong(res);
Py_DECREF(res);
if (isatty == -1 && PyErr_Occurred())
goto error;
}
if (buffering == 1 || (buffering < 0 && isatty)) {
buffering = -1;
line_buffering = 1;
}
else
line_buffering = 0;
Python Code to reproduce:
with open('foo', 'rb', buffering=0) as f:
f.read()
This generates an error (can be seen with strace):
ioctl(5, TCGETS, 0x7ffef1435b60) = -1 ENOTTY (Inappropriate ioctl for device)
I'll open a PR shortly. |
|
Date |
User |
Action |
Args |
2018-07-08 18:12:53 | Dav1d | set | recipients:
+ Dav1d |
2018-07-08 18:12:53 | Dav1d | set | messageid: <1531073573.35.0.56676864532.issue34070@psf.upfronthosting.co.za> |
2018-07-08 18:12:53 | Dav1d | link | issue34070 messages |
2018-07-08 18:12:53 | Dav1d | create | |
|