mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
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:
parent
6d1c149a46
commit
8b63d3af9f
2 changed files with 4 additions and 6 deletions
|
@ -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")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue