Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder2.enfer-du-nord.net!tudelft.nl!txtfeed1.tudelft.nl!dedekind.zen.co.uk!zen.net.uk!hamilton.zen.co.uk!prichard.zen.co.uk.POSTED!not-for-mail From: Nobody Subject: Re: try... except with unknown error types Date: Sat, 10 Sep 2011 10:33:03 +0100 User-Agent: Pan/0.14.2 (This is not a psychotic episode. It's a cleansing moment of clarity.) Message-Id: Newsgroups: comp.lang.python References: <4e5015ad$0$29986$c3e8da3$5496439d@news.astraweb.com> <7xty9ahb84.fsf@ruckus.brouhaha.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Lines: 15 Organization: Zen Internet NNTP-Posting-Host: a0f484bb.news.zen.co.uk X-Trace: DXC=fmS3eQ>E`8EX=9H01;iQAL0g@SS;SF6nGR9OH0:RnEND:hoe0Z_FD?Fm=2n=fg=<7Gd_LU`RI;4IA X-Complaints-To: abuse@zen.co.uk Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:13057 On Wed, 31 Aug 2011 21:01:34 +0000, Chris Torek wrote: > Still, it sure would be nice to have a static analysis > tool that could answer questions about potential exceptions. :-) ) That's an impossibility in a dynamic language. If you call f.read() where f was passed in as a parameter, the exceptions which f.read() may throw depend upon exactly what f is; there's no guarantee that it will actually be a built-in file object, only that it will have a .read() method (otherwise you will get an AttributeError). Even if f was returned from open(), there's no guarantee that __builtins__.open() won't have been replaced by the time of the call.