Author christian.heimes
Recipients alex, christian.heimes, corona10, dstufft, janssen, vstinner
Date 2020-11-19.19:10:42
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1605813042.63.0.217434537297.issue42413@roundup.psfhosted.org>
In-reply-to
Content
The socket module has a custom timeout exception "socket.timeout". The exception is documented https://docs.python.org/3/library/socket.html#socket.timeout as :

> A subclass of OSError, this exception is raised when a timeout occurs on a socket which has had timeouts enabled via a prior call to settimeout() (or implicitly through setdefaulttimeout()).

It's a distinct exception type and not the same as the global TimeoutError.

>>> import socket
>>> socket.timeout == TimeoutError
False

I like to follow the example of the deprecated "socket.error", replace the custom exception and make it an alias of TimeoutError. The risk is minimal. Both exceptions are subclasses of OSError.

The change would not only make exception handling more consistent. It would also allow me to simplify some code in ssl and socket C code. I might even be able to remove the socket CAPI import from _ssl.c completely.
History
Date User Action Args
2020-11-19 19:10:42christian.heimessetrecipients: + christian.heimes, janssen, vstinner, alex, dstufft, corona10
2020-11-19 19:10:42christian.heimessetmessageid: <1605813042.63.0.217434537297.issue42413@roundup.psfhosted.org>
2020-11-19 19:10:42christian.heimeslinkissue42413 messages
2020-11-19 19:10:42christian.heimescreate