diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2010-09-07 21:43:31 (GMT) |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2010-09-07 21:43:31 (GMT) |
commit | 2673c5bf5e9640bd2fbdc20c03dd7e95e39310e0 (patch) | |
tree | b4b62cbcf417c67fd769ad107bf058550c838735 /Lib | |
parent | cc6aac60da1e9ccf55052773c4fb6e5f91de5436 (diff) | |
download | cpython-2673c5bf5e9640bd2fbdc20c03dd7e95e39310e0.zip cpython-2673c5bf5e9640bd2fbdc20c03dd7e95e39310e0.tar.gz cpython-2673c5bf5e9640bd2fbdc20c03dd7e95e39310e0.tar.bz2 |
Also catch some gaierrors
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/support.py | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/Lib/test/support.py b/Lib/test/support.py index 6ce5ebf..bff4637 100644 --- a/Lib/test/support.py +++ b/Lib/test/support.py @@ -793,16 +793,25 @@ def transient_internet(resource_name, *, timeout=30.0, errnos=()): ('ENETUNREACH', 101), ('ETIMEDOUT', 110), ] + default_gai_errnos = [ + ('EAI_NONAME', -2), + ('EAI_NODATA', -5), + ] denied = ResourceDenied("Resource '%s' is not available" % resource_name) captured_errnos = errnos + gai_errnos = [] if not captured_errnos: captured_errnos = [getattr(errno, name, num) for (name, num) in default_errnos] + gai_errnos = [getattr(socket, name, num) + for (name, num) in default_gai_errnos] def filter_error(err): + n = getattr(err, 'errno', None) if (isinstance(err, socket.timeout) or - getattr(err, 'errno', None) in captured_errnos): + (isinstance(err, socket.gaierror) and n in gai_errnos) or + n in captured_errnos): if not verbose: sys.stderr.write(denied.args[0] + "\n") raise denied from err |