mirror of
https://github.com/python/cpython.git
synced 2025-12-08 06:10:17 +00:00
gh-140748: socket_helper.transient_internet: Unwrap UrlError.__cause__ (GH-140749)
This commit is contained in:
parent
134adb32e8
commit
75a1cbdd38
1 changed files with 4 additions and 0 deletions
|
|
@ -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)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue