Steven D'Aprano <steve+comp.lang.pyt...@pearwood.info>: > On Mon, 07 Jul 2014 22:19:20 +1000, Chris Angelico wrote: > >> It's possible for input() to raise IOError, if I'm not mistaken; >> consider redirection, for instance. > > What indirection? Do you mean, if built-in input() has been monkey- > patched? Well, sure, but in that case it could do anything. I'm only > concerned with the builtins. Otherwise, I have no idea what you mean > by that.
input() quite naturally can raise an IOError. For example: import os, socket s = socket.socket(socket.AF_UNIX) s.bind("xyz") os.dup2(s.fileno(), 0); print(input()) results in an IOError (EINVAL, to be exact). strace reveals that input() simply delegates to: read(0, 0xb73aa000, 4096) = -1 EINVAL (Invalid argument) Marko -- https://mail.python.org/mailman/listinfo/python-list