Issue #22596: support.transient_internet() now also catches

ConnectionRefusedError exceptions wrapped by urllib.error.URLError.

This change should fix sporadic failures in test_urllib2net.
This commit is contained in:
Berker Peksag 2014-10-25 05:42:30 +03:00
parent 6d1c149a46
commit 8b63d3af9f
2 changed files with 4 additions and 6 deletions

View file

@ -25,6 +25,7 @@ import sysconfig
import tempfile
import time
import unittest
import urllib.error
import warnings
try:
@ -1307,6 +1308,8 @@ def transient_internet(resource_name, *, timeout=30.0, errnos=()):
n = getattr(err, 'errno', None)
if (isinstance(err, socket.timeout) or
(isinstance(err, socket.gaierror) and n in gai_errnos) or
(isinstance(err, urllib.error.URLError) and
"ConnectionRefusedError" in err.reason) or
n in captured_errnos):
if not verbose:
sys.stderr.write(denied.args[0] + "\n")