From 46854a76604c88b960958ebed0ec58c51b417486 Mon Sep 17 00:00:00 2001 From: delobanov <37274413+delobanov@users.noreply.github.com> Date: Wed, 28 Aug 2024 23:41:38 +0300 Subject: [PATCH] Fix ConnectionError() takes no keyword arguments with proxies (#4440) --- telethon/network/connection/connection.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/telethon/network/connection/connection.py b/telethon/network/connection/connection.py index 838b3b88..fa034013 100644 --- a/telethon/network/connection/connection.py +++ b/telethon/network/connection/connection.py @@ -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