New submission from Christian Heimes <li...@cheimes.de>:

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.

----------
assignee: christian.heimes
components: Extension Modules
messages: 381454
nosy: alex, christian.heimes, corona10, dstufft, janssen, vstinner
priority: normal
severity: normal
status: open
title: Replace custom exception socket.timeout with TimeoutError
type: enhancement
versions: Python 3.10

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue42413>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to