Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Marko Rauhamaa Newsgroups: comp.lang.python Subject: Re: open() and EOFError Date: Mon, 07 Jul 2014 19:08:46 +0300 Organization: A noiseless patient Spider Lines: 27 Message-ID: <87a98lb181.fsf@elektro.pacujo.net> References: <53ba11fc$0$29985$c3e8da3$5496439d@news.astraweb.com> <53ba538d$0$2926$c3e8da3$76491128@news.astraweb.com> <53bac097$0$29995$c3e8da3$5496439d@news.astraweb.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: mx05.eternal-september.org; posting-host="ff5cf27ef3d5b31f034d3b72bdc27a41"; logging-data="17767"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+je/v31YelYdI8zmJlpuMK" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.3 (gnu/linux) Cancel-Lock: sha1:woIYISBR3Y9kDs+NONaxVpqYga8= sha1:D9Y48enjvmlU1QAXzWH9dwwlATw= Xref: csiph.com comp.lang.python:74121 Steven D'Aprano : > 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