On 4/1/2017 3:27 PM, Ram Rachum wrote:
Today I got burned because I had code that did this:
except TimeoutError:
When it should have done this:
except socket.timeout:
Both are subclasses of OSError but mean different things. TimeoutError
means that something in 'your system' did not respond. Socket.timeout
means that a foreign system did not respond. (I am leaving out a local
socket connection.) The latter can only happen with a socket call with
timeouts enabled. If it is possible for TimeoutError to also occur with
a timeout-enabled socket call, then one might very well want to only
catch one or catch them separately and respond differently.
There's also another timeout error class in asyncio.
Which can only happen when using asyncio.
-1 on merging, +1 on staying with the current design. What I write
above is similar to Guido's explanation for asyncio.TimeoutError.
--
Terry Jan Reedy
_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/