Fix ConnectionError() takes no keyword arguments with proxies (#4440)

This commit is contained in:
delobanov 2024-08-28 23:41:38 +03:00 committed by GitHub
parent 90f1e5b073
commit 46854a7660
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -116,9 +116,15 @@ class Connection(abc.ABC):
# python_socks internal errors are not inherited from
# builtin IOError (just from Exception). Instead of adding those
# in exceptions clauses everywhere through the code, we
# rather monkey-patch them in place.
# rather monkey-patch them in place. Keep in mind that
# ProxyError takes error_code as keyword argument.
python_socks._errors.ProxyError = ConnectionError
class ConnectionErrorExtra(ConnectionError):
def __init__(self, message, error_code=None):
super().__init__()
self.error_code = error_code
python_socks._errors.ProxyError = ConnectionErrorExtra
python_socks._errors.ProxyConnectionError = ConnectionError
python_socks._errors.ProxyTimeoutError = ConnectionError