Martijn Pieters added the comment: This bug affects all use of `file.__iter__` and interrupts (EINTR), not just sys.stdin.
You can reproduce the issue by reading from a (slow) pipe in a terminal window and resizing that window, for example; the interrupt is not handled and a future call ends up raising `IOError: [Errno 0] Error`, a rather confusing message. The Mercurial community is switching away from using direct iteration over this bug; Jun's excellent analysis is included and enlightening: https://www.mercurial-scm.org/pipermail/mercurial-devel/2016-November/090522.html The fix is to use interrupted = ferror(f->f_fp) && errno == EINTR; // .. if (interrupted) { clearerr(f->f_fp); if (PyErr_CheckSignals()) { Py_DECREF(v); return NULL; } } and check for interrupted == 0 in the chunksize == 0 case after Py_UniversalNewlineFread calls, as file_read does, for example, but which readahead doesn't (where the only public user of readahead is file_iternext). ---------- nosy: +mjpieters _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue1633941> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com