In article <mailman.286.1313956388.27778.python-l...@python.org>, Terry Reedy <tjre...@udel.edu> wrote: >I would expect that catching socket.error (or even IOError) should catch >all of those. > >"exception socket.error >A subclass of IOError ...
Except that, as Steven D'Aprano almost noted elsethread, it isn't (a subclass of IOError -- the note was that it is not a subclass of EnvironmentError). In 2.x anyway: >>> import socket >>> isinstance(socket.error, IOError) False >>> isinstance(socket.error, EnvironmentError) False >>> (I just catch socket.error directly for this case.) (I have also never been sure whether something is going to raise an IOError or an OSError for various OS-related read or write operation failures -- such as exceeding a resource limit, for instance -- so most places that do I/O operations on OS files, I catch both. Still, it sure would be nice to have a static analysis tool that could answer questions about potential exceptions. :-) ) -- In-Real-Life: Chris Torek, Wind River Systems Intel require I note that my opinions are not those of WRS or Intel Salt Lake City, UT, USA (40°39.22'N, 111°50.29'W) +1 801 277 2603 email: gmail (figure it out) http://web.torek.net/torek/index.html
-- http://mail.python.org/mailman/listinfo/python-list