jenkins-bot has submitted this change. ( 
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1327613?usp=email )

Change subject: [fix] raise ConnectionError for lost SOCKS connection
......................................................................

[fix] raise ConnectionError for lost SOCKS connection

Bug: T430263
Change-Id: I0cc82d7715a92788e8c158dc3afda2b236a6cb07
---
M pywikibot/comms/http.py
1 file changed, 16 insertions(+), 2 deletions(-)

Approvals:
  Xqt: Looks good to me, approved
  jenkins-bot: Verified




diff --git a/pywikibot/comms/http.py b/pywikibot/comms/http.py
index d7acd27..8eecccd 100644
--- a/pywikibot/comms/http.py
+++ b/pywikibot/comms/http.py
@@ -376,8 +376,22 @@

     if isinstance(response, requests.ConnectionError):
         msg = str(response)
-        if ('NewConnectionError' in msg or 'NameResolutionError' in msg) \
-           and re.search(r'\[Errno (-2|8|11001)\]', msg):
+
+        is_known_connection_error = (
+            ('NewConnectionError' in msg or 'NameResolutionError' in msg)
+            and any(f'[Errno {errno}]' in msg for errno in (-2, 8, 11001))
+        )
+
+        is_socks_disconnect = all(
+            text in msg
+            for text in (
+                'NewConnectionError',
+                'SOCKSConnection',
+                'Connection closed unexpectedly',
+            )
+        )
+
+        if is_known_connection_error or is_socks_disconnect:
             raise ConnectionError(response)

     # catch requests.ReadTimeout and requests.ConnectTimeout and convert

--
To view, visit 
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1327613?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.wikimedia.org/r/settings?usp=email

Gerrit-MessageType: merged
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: I0cc82d7715a92788e8c158dc3afda2b236a6cb07
Gerrit-Change-Number: 1327613
Gerrit-PatchSet: 2
Gerrit-Owner: Xqt <[email protected]>
Gerrit-Reviewer: Xqt <[email protected]>
Gerrit-Reviewer: jenkins-bot
Gerrit-CC: Mahveotm <[email protected]>
_______________________________________________
Pywikibot-commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to