https://github.com/python/cpython/commit/55cf97d8dd269c45a65a4ceba082d04f16f0eafd commit: 55cf97d8dd269c45a65a4ceba082d04f16f0eafd branch: 3.14 author: Miss Islington (bot) <[email protected]> committer: encukou <[email protected]> date: 2025-11-13T13:58:37+01:00 summary:
[3.14] gh-140748: socket_helper.transient_internet: Unwrap UrlError.__cause__ (GH-140749) (GH-141505) (cherry picked from commit 75a1cbdd38b142b359849eae16a2ecc12f6b3881) Co-authored-by: Petr Viktorin <[email protected]> files: M Lib/test/support/socket_helper.py diff --git a/Lib/test/support/socket_helper.py b/Lib/test/support/socket_helper.py index 87941ee1791b4e..a41e487f3e4bc5 100644 --- a/Lib/test/support/socket_helper.py +++ b/Lib/test/support/socket_helper.py @@ -259,6 +259,10 @@ def filter_error(err): # raise OSError('socket error', msg) from msg elif len(a) >= 2 and isinstance(a[1], OSError): err = a[1] + # The error can also be wrapped as __cause__: + # raise URLError(f"ftp error: {exp}") from exp + elif isinstance(err, urllib.error.URLError) and err.__cause__: + err = err.__cause__ else: break filter_error(err) _______________________________________________ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3//lists/python-checkins.python.org Member address: [email protected]
