Skip to content

Commit 9f3760b

Browse files
committed
Upgrade urllib3 to 1.26.8
1 parent cc21ec2 commit 9f3760b

File tree

12 files changed

+66
-46
lines changed

12 files changed

+66
-46
lines changed

news/urllib3.vendor.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Upgrade urllib3 to 1.26.8

src/pip/_vendor/urllib3/_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
# This file is protected via CODEOWNERS
2-
__version__ = "1.26.7"
2+
__version__ = "1.26.8"

src/pip/_vendor/urllib3/connection.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ class BrokenPipeError(Exception):
5151
SubjectAltNameWarning,
5252
SystemTimeWarning,
5353
)
54-
from .packages.ssl_match_hostname import CertificateError, match_hostname
5554
from .util import SKIP_HEADER, SKIPPABLE_HEADERS, connection
5655
from .util.ssl_ import (
5756
assert_fingerprint,
@@ -61,6 +60,7 @@ class BrokenPipeError(Exception):
6160
resolve_ssl_version,
6261
ssl_wrap_socket,
6362
)
63+
from .util.ssl_match_hostname import CertificateError, match_hostname
6464

6565
log = logging.getLogger(__name__)
6666

src/pip/_vendor/urllib3/connectionpool.py

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import errno
44
import logging
5+
import re
56
import socket
67
import sys
78
import warnings
@@ -35,7 +36,6 @@
3536
)
3637
from .packages import six
3738
from .packages.six.moves import queue
38-
from .packages.ssl_match_hostname import CertificateError
3939
from .request import RequestMethods
4040
from .response import HTTPResponse
4141
from .util.connection import is_connection_dropped
@@ -44,6 +44,7 @@
4444
from .util.request import set_file_position
4545
from .util.response import assert_header_parsing
4646
from .util.retry import Retry
47+
from .util.ssl_match_hostname import CertificateError
4748
from .util.timeout import Timeout
4849
from .util.url import Url, _encode_target
4950
from .util.url import _normalize_host as normalize_host
@@ -301,8 +302,11 @@ def _put_conn(self, conn):
301302
pass
302303
except queue.Full:
303304
# This should never happen if self.block == True
304-
log.warning("Connection pool is full, discarding connection: %s", self.host)
305-
305+
log.warning(
306+
"Connection pool is full, discarding connection: %s. Connection pool size: %s",
307+
self.host,
308+
self.pool.qsize(),
309+
)
306310
# Connection never got put back into the pool, close it.
307311
if conn:
308312
conn.close()
@@ -745,7 +749,33 @@ def urlopen(
745749
# Discard the connection for these exceptions. It will be
746750
# replaced during the next _get_conn() call.
747751
clean_exit = False
748-
if isinstance(e, (BaseSSLError, CertificateError)):
752+
753+
def _is_ssl_error_message_from_http_proxy(ssl_error):
754+
# We're trying to detect the message 'WRONG_VERSION_NUMBER' but
755+
# SSLErrors are kinda all over the place when it comes to the message,
756+
# so we try to cover our bases here!
757+
message = " ".join(re.split("[^a-z]", str(ssl_error).lower()))
758+
return (
759+
"wrong version number" in message or "unknown protocol" in message
760+
)
761+
762+
# Try to detect a common user error with proxies which is to
763+
# set an HTTP proxy to be HTTPS when it should be 'http://'
764+
# (ie {'http': 'http://proxy', 'https': 'https://proxy'})
765+
# Instead we add a nice error message and point to a URL.
766+
if (
767+
isinstance(e, BaseSSLError)
768+
and self.proxy
769+
and _is_ssl_error_message_from_http_proxy(e)
770+
):
771+
e = ProxyError(
772+
"Your proxy appears to only use HTTP and not HTTPS, "
773+
"try changing your proxy URL to be HTTP. See: "
774+
"https://urllib3.readthedocs.io/en/1.26.x/advanced-usage.html"
775+
"#https-proxy-error-http-proxy",
776+
SSLError(e),
777+
)
778+
elif isinstance(e, (BaseSSLError, CertificateError)):
749779
e = SSLError(e)
750780
elif isinstance(e, (SocketError, NewConnectionError)) and self.proxy:
751781
e = ProxyError("Cannot connect to proxy.", e)

src/pip/_vendor/urllib3/contrib/_securetransport/bindings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
)
4949
from ctypes.util import find_library
5050

51-
from pip._vendor.urllib3.packages.six import raise_from
51+
from ...packages.six import raise_from
5252

5353
if platform.system() != "Darwin":
5454
raise ImportError("Only macOS is supported")
Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +0,0 @@
1-
from __future__ import absolute_import
2-
3-
from . import ssl_match_hostname
4-
5-
__all__ = ("ssl_match_hostname",)

src/pip/_vendor/urllib3/packages/ssl_match_hostname/__init__.py

Lines changed: 0 additions & 24 deletions
This file was deleted.

src/pip/_vendor/urllib3/util/connection.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@
22

33
import socket
44

5-
from pip._vendor.urllib3.exceptions import LocationParseError
6-
75
from ..contrib import _appengine_environ
6+
from ..exceptions import LocationParseError
87
from ..packages import six
98
from .wait import NoWayToWaitForSocketError, wait_for_read
109

src/pip/_vendor/urllib3/util/retry.py

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,24 @@ def DEFAULT_REDIRECT_HEADERS_BLACKLIST(cls, value):
6969
)
7070
cls.DEFAULT_REMOVE_HEADERS_ON_REDIRECT = value
7171

72+
@property
73+
def BACKOFF_MAX(cls):
74+
warnings.warn(
75+
"Using 'Retry.BACKOFF_MAX' is deprecated and "
76+
"will be removed in v2.0. Use 'Retry.DEFAULT_BACKOFF_MAX' instead",
77+
DeprecationWarning,
78+
)
79+
return cls.DEFAULT_BACKOFF_MAX
80+
81+
@BACKOFF_MAX.setter
82+
def BACKOFF_MAX(cls, value):
83+
warnings.warn(
84+
"Using 'Retry.BACKOFF_MAX' is deprecated and "
85+
"will be removed in v2.0. Use 'Retry.DEFAULT_BACKOFF_MAX' instead",
86+
DeprecationWarning,
87+
)
88+
cls.DEFAULT_BACKOFF_MAX = value
89+
7290

7391
@six.add_metaclass(_RetryMeta)
7492
class Retry(object):
@@ -181,7 +199,7 @@ class Retry(object):
181199
182200
seconds. If the backoff_factor is 0.1, then :func:`.sleep` will sleep
183201
for [0.0s, 0.2s, 0.4s, ...] between retries. It will never be longer
184-
than :attr:`Retry.BACKOFF_MAX`.
202+
than :attr:`Retry.DEFAULT_BACKOFF_MAX`.
185203
186204
By default, backoff is disabled (set to 0).
187205
@@ -220,7 +238,7 @@ class Retry(object):
220238
DEFAULT_REMOVE_HEADERS_ON_REDIRECT = frozenset(["Authorization"])
221239

222240
#: Maximum backoff time.
223-
BACKOFF_MAX = 120
241+
DEFAULT_BACKOFF_MAX = 120
224242

225243
def __init__(
226244
self,
@@ -348,7 +366,7 @@ def get_backoff_time(self):
348366
return 0
349367

350368
backoff_value = self.backoff_factor * (2 ** (consecutive_errors_len - 1))
351-
return min(self.BACKOFF_MAX, backoff_value)
369+
return min(self.DEFAULT_BACKOFF_MAX, backoff_value)
352370

353371
def parse_retry_after(self, retry_after):
354372
# Whitespace: https://tools.ietf.org/html/rfc7230#section-3.2.4

src/pip/_vendor/urllib3/packages/ssl_match_hostname/_implementation.py renamed to src/pip/_vendor/urllib3/util/ssl_match_hostname.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
# ipaddress has been backported to 2.6+ in pypi. If it is installed on the
1010
# system, use it to handle IPAddress ServerAltnames (this was added in
1111
# python-3.5) otherwise only do DNS matching. This allows
12-
# backports.ssl_match_hostname to continue to be used in Python 2.7.
12+
# util.ssl_match_hostname to continue to be used in Python 2.7.
1313
try:
1414
import ipaddress
1515
except ImportError:
@@ -78,7 +78,8 @@ def _dnsname_match(dn, hostname, max_wildcards=1):
7878

7979
def _to_unicode(obj):
8080
if isinstance(obj, str) and sys.version_info < (3,):
81-
obj = unicode(obj, encoding="ascii", errors="strict")
81+
# ignored flake8 # F821 to support python 2.7 function
82+
obj = unicode(obj, encoding="ascii", errors="strict") # noqa: F821
8283
return obj
8384

8485

src/pip/_vendor/urllib3/util/ssltransport.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
import socket
33
import ssl
44

5-
from pip._vendor.urllib3.exceptions import ProxySchemeUnsupported
6-
from pip._vendor.urllib3.packages import six
5+
from ..exceptions import ProxySchemeUnsupported
6+
from ..packages import six
77

88
SSL_BLOCKSIZE = 16384
99

src/pip/_vendor/vendor.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ requests==2.27.1
1313
certifi==2021.05.30
1414
chardet==4.0.0
1515
idna==3.2
16-
urllib3==1.26.7
16+
urllib3==1.26.8
1717
rich==10.14.0
1818
pygments==2.10.0
1919
typing_extensions==3.10.0.2

0 commit comments

Comments
 (0)