gh-140748: socket_helper.transient_internet: Unwrap UrlError.__cause__ (GH-140749)

This commit is contained in:
Petr Viktorin 2025-10-30 12:14:17 +01:00 committed by GitHub
parent 134adb32e8
commit 75a1cbdd38
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -259,6 +259,10 @@ def filter_error(err):
# raise OSError('socket error', msg) from msg # raise OSError('socket error', msg) from msg
elif len(a) >= 2 and isinstance(a[1], OSError): elif len(a) >= 2 and isinstance(a[1], OSError):
err = a[1] 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: else:
break break
filter_error(err) filter_error(err)