Patrick Williams | 169d7bc | 2024-01-05 11:33:25 -0600 | [diff] [blame] | 1 | From 7293cfae4fd68004901825ad1cabb83424d8729a Mon Sep 17 00:00:00 2001 |
| 2 | From: serge-sans-paille <sguelton@mozilla.com> |
| 3 | Date: Mon, 16 Oct 2023 13:35:24 +0000 |
| 4 | Subject: [PATCH] Bug 1857492 - Upgrade vendored version of six and urllib3 |
| 5 | r=saschanaz |
| 6 | |
| 7 | six -> 1.16 |
| 8 | urllib3 -> 1.26.17 |
| 9 | |
| 10 | Differential Revision: https://phabricator.services.mozilla.com/D190288 |
| 11 | Upstream-Status: Backport [https://github.com/mozilla/gecko-dev/commit/7293cfae4fd68004901825ad1cabb83424d8729a] |
| 12 | Signed-off-by: Alexander Kanavin <alex@linutronix.de> |
| 13 | --- |
| 14 | third_party/python/poetry.lock | 22 +-- |
| 15 | third_party/python/requirements.in | 4 +- |
| 16 | third_party/python/requirements.txt | 12 +- |
| 17 | .../python/six/six-1.13.0.dist-info/RECORD | 6 - |
| 18 | .../LICENSE | 2 +- |
| 19 | .../METADATA | 9 +- |
| 20 | .../python/six/six-1.16.0.dist-info/RECORD | 6 + |
| 21 | .../six-1.16.0.dist-info}/WHEEL | 2 +- |
| 22 | .../top_level.txt | 0 |
| 23 | third_party/python/six/six.py | 91 ++++++--- |
| 24 | .../urllib3/urllib3-1.26.0.dist-info/RECORD | 44 ----- |
| 25 | .../LICENSE.txt | 0 |
| 26 | .../METADATA | 177 ++++++++++++++++-- |
| 27 | .../urllib3/urllib3-1.26.17.dist-info/RECORD | 44 +++++ |
| 28 | .../urllib3-1.26.17.dist-info}/WHEEL | 2 +- |
| 29 | .../top_level.txt | 0 |
| 30 | .../python/urllib3/urllib3/__init__.py | 17 ++ |
| 31 | .../python/urllib3/urllib3/_version.py | 2 +- |
| 32 | .../python/urllib3/urllib3/connection.py | 62 ++++-- |
| 33 | .../python/urllib3/urllib3/connectionpool.py | 97 ++++++++-- |
| 34 | .../contrib/_securetransport/bindings.py | 2 +- |
| 35 | .../contrib/_securetransport/low_level.py | 1 + |
| 36 | .../urllib3/urllib3/contrib/appengine.py | 4 +- |
| 37 | .../urllib3/urllib3/contrib/ntlmpool.py | 13 +- |
| 38 | .../urllib3/urllib3/contrib/pyopenssl.py | 19 +- |
| 39 | .../urllib3/contrib/securetransport.py | 5 +- |
| 40 | .../python/urllib3/urllib3/contrib/socks.py | 2 +- |
| 41 | .../python/urllib3/urllib3/exceptions.py | 12 +- |
| 42 | .../urllib3/urllib3/packages/__init__.py | 5 - |
| 43 | .../packages/backports/weakref_finalize.py | 155 +++++++++++++++ |
| 44 | .../python/urllib3/urllib3/packages/six.py | 125 +++++++++---- |
| 45 | .../packages/ssl_match_hostname/__init__.py | 22 --- |
| 46 | .../python/urllib3/urllib3/poolmanager.py | 3 +- |
| 47 | third_party/python/urllib3/urllib3/request.py | 21 +++ |
| 48 | .../python/urllib3/urllib3/response.py | 72 ++++++- |
| 49 | .../python/urllib3/urllib3/util/connection.py | 5 +- |
| 50 | .../python/urllib3/urllib3/util/proxy.py | 1 + |
| 51 | .../python/urllib3/urllib3/util/request.py | 5 +- |
| 52 | .../python/urllib3/urllib3/util/retry.py | 37 +++- |
| 53 | .../python/urllib3/urllib3/util/ssl_.py | 53 ++++-- |
| 54 | .../ssl_match_hostname.py} | 15 +- |
| 55 | .../urllib3/urllib3/util/ssltransport.py | 6 +- |
| 56 | .../python/urllib3/urllib3/util/timeout.py | 9 +- |
| 57 | .../python/urllib3/urllib3/util/url.py | 17 +- |
| 58 | .../python/urllib3/urllib3/util/wait.py | 1 - |
| 59 | 45 files changed, 934 insertions(+), 275 deletions(-) |
| 60 | delete mode 100644 third_party/python/six/six-1.13.0.dist-info/RECORD |
| 61 | rename third_party/python/six/{six-1.13.0.dist-info => six-1.16.0.dist-info}/LICENSE (96%) |
| 62 | rename third_party/python/six/{six-1.13.0.dist-info => six-1.16.0.dist-info}/METADATA (85%) |
| 63 | create mode 100644 third_party/python/six/six-1.16.0.dist-info/RECORD |
| 64 | rename third_party/python/{urllib3/urllib3-1.26.0.dist-info => six/six-1.16.0.dist-info}/WHEEL (70%) |
| 65 | rename third_party/python/six/{six-1.13.0.dist-info => six-1.16.0.dist-info}/top_level.txt (100%) |
| 66 | delete mode 100644 third_party/python/urllib3/urllib3-1.26.0.dist-info/RECORD |
| 67 | rename third_party/python/urllib3/{urllib3-1.26.0.dist-info => urllib3-1.26.17.dist-info}/LICENSE.txt (100%) |
| 68 | rename third_party/python/urllib3/{urllib3-1.26.0.dist-info => urllib3-1.26.17.dist-info}/METADATA (86%) |
| 69 | create mode 100644 third_party/python/urllib3/urllib3-1.26.17.dist-info/RECORD |
| 70 | rename third_party/python/{six/six-1.13.0.dist-info => urllib3/urllib3-1.26.17.dist-info}/WHEEL (70%) |
| 71 | rename third_party/python/urllib3/{urllib3-1.26.0.dist-info => urllib3-1.26.17.dist-info}/top_level.txt (100%) |
| 72 | create mode 100644 third_party/python/urllib3/urllib3/packages/backports/weakref_finalize.py |
| 73 | delete mode 100644 third_party/python/urllib3/urllib3/packages/ssl_match_hostname/__init__.py |
| 74 | rename third_party/python/urllib3/urllib3/{packages/ssl_match_hostname/_implementation.py => util/ssl_match_hostname.py} (92%) |
| 75 | |
| 76 | diff --git a/third_party/python/poetry.lock b/third_party/python/poetry.lock |
| 77 | index 3d50174e58bcb..b4a8455d20fb4 100644 |
| 78 | --- a/third_party/python/poetry.lock |
| 79 | +++ b/third_party/python/poetry.lock |
| 80 | @@ -1333,14 +1333,14 @@ testing-integration = ["build[virtualenv]", "filelock (>=3.4.0)", "jaraco.envs ( |
| 81 | |
| 82 | [[package]] |
| 83 | name = "six" |
| 84 | -version = "1.13.0" |
| 85 | +version = "1.16.0" |
| 86 | description = "Python 2 and 3 compatibility utilities" |
| 87 | category = "main" |
| 88 | optional = false |
| 89 | -python-versions = ">=2.6, !=3.0.*, !=3.1.*" |
| 90 | +python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*" |
| 91 | files = [ |
| 92 | - {file = "six-1.13.0-py2.py3-none-any.whl", hash = "sha256:1f1b7d42e254082a9db6279deae68afb421ceba6158efa6131de7b3003ee93fd"}, |
| 93 | - {file = "six-1.13.0.tar.gz", hash = "sha256:30f610279e8b2578cab6db20741130331735c781b56053c59c4076da27f06b66"}, |
| 94 | + {file = "six-1.16.0-py2.py3-none-any.whl", hash = "sha256:8abb2f1d86890a2dfb989f9a77cfcfd3e47c2a354b01111771326f8aa26e0254"}, |
| 95 | + {file = "six-1.16.0.tar.gz", hash = "sha256:1e61c37477a1626458e36f7b1d82aa5c9b094fa4802892072e49de9c60c4c926"}, |
| 96 | ] |
| 97 | |
| 98 | [[package]] |
| 99 | @@ -1491,19 +1491,19 @@ files = [ |
| 100 | |
| 101 | [[package]] |
| 102 | name = "urllib3" |
| 103 | -version = "1.26.0" |
| 104 | +version = "1.26.17" |
| 105 | description = "HTTP library with thread-safe connection pooling, file post, and more." |
| 106 | category = "main" |
| 107 | optional = false |
| 108 | -python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, <4" |
| 109 | +python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, !=3.5.*" |
| 110 | files = [ |
| 111 | - {file = "urllib3-1.26.0-py2.py3-none-any.whl", hash = "sha256:bad31cb622ceee0ab46c4c884cf61957def0ff2e644de0a7a093678844c9ccac"}, |
| 112 | - {file = "urllib3-1.26.0.tar.gz", hash = "sha256:4849f132941d68144df0a3785ccc4fe423430ba5db0108d045c8cadbc90f517a"}, |
| 113 | + {file = "urllib3-1.26.17-py2.py3-none-any.whl", hash = "sha256:94a757d178c9be92ef5539b8840d48dc9cf1b2709c9d6b588232a055c524458b"}, |
| 114 | + {file = "urllib3-1.26.17.tar.gz", hash = "sha256:24d6a242c28d29af46c3fae832c36db3bbebcc533dd1bb549172cd739c82df21"}, |
| 115 | ] |
| 116 | |
| 117 | [package.extras] |
| 118 | -brotli = ["brotlipy (>=0.6.0)"] |
| 119 | -secure = ["certifi", "cryptography (>=1.3.4)", "idna (>=2.0.0)", "ipaddress", "pyOpenSSL (>=0.14)"] |
| 120 | +brotli = ["brotli (==1.0.9)", "brotli (>=1.0.9)", "brotlicffi (>=0.8.0)", "brotlipy (>=0.6.0)"] |
| 121 | +secure = ["certifi", "cryptography (>=1.3.4)", "idna (>=2.0.0)", "ipaddress", "pyOpenSSL (>=0.14)", "urllib3-secure-extra"] |
| 122 | socks = ["PySocks (>=1.5.6,!=1.5.7,<2.0)"] |
| 123 | |
| 124 | [[package]] |
| 125 | diff --git a/third_party/python/six/six-1.13.0.dist-info/RECORD b/third_party/python/six/six-1.13.0.dist-info/RECORD |
| 126 | deleted file mode 100644 |
| 127 | index a0e6c1fd4bd99..0000000000000 |
| 128 | --- a/third_party/python/six/six-1.13.0.dist-info/RECORD |
| 129 | +++ /dev/null |
| 130 | @@ -1,6 +0,0 @@ |
| 131 | -six.py,sha256=bsEzSFTZTx49wQttLORmSZTrpjGc8UbXt-HBa_LZX7Q,33045 |
| 132 | -six-1.13.0.dist-info/LICENSE,sha256=t1KbjAcXGniow2wyg5BVKOSBKUXZd9El65JujMvyRbY,1066 |
| 133 | -six-1.13.0.dist-info/METADATA,sha256=hxS4rSPRfO8ewbcLS30anoFi6LFgUQ3mk_xknZ8RV4w,1940 |
| 134 | -six-1.13.0.dist-info/WHEEL,sha256=8zNYZbwQSXoB9IfXOjPfeNwvAsALAjffgk27FqvCWbo,110 |
| 135 | -six-1.13.0.dist-info/top_level.txt,sha256=_iVH_iYEtEXnD8nYGQYpYFUvkUW9sEO1GYbkeKSAais,4 |
| 136 | -six-1.13.0.dist-info/RECORD,, |
| 137 | diff --git a/third_party/python/six/six-1.13.0.dist-info/LICENSE b/third_party/python/six/six-1.16.0.dist-info/LICENSE |
| 138 | similarity index 96% |
| 139 | rename from third_party/python/six/six-1.13.0.dist-info/LICENSE |
| 140 | rename to third_party/python/six/six-1.16.0.dist-info/LICENSE |
| 141 | index 4b05a545261c0..de6633112c1f9 100644 |
| 142 | --- a/third_party/python/six/six-1.13.0.dist-info/LICENSE |
| 143 | +++ b/third_party/python/six/six-1.16.0.dist-info/LICENSE |
| 144 | @@ -1,4 +1,4 @@ |
| 145 | -Copyright (c) 2010-2019 Benjamin Peterson |
| 146 | +Copyright (c) 2010-2020 Benjamin Peterson |
| 147 | |
| 148 | Permission is hereby granted, free of charge, to any person obtaining a copy of |
| 149 | this software and associated documentation files (the "Software"), to deal in |
| 150 | diff --git a/third_party/python/six/six-1.13.0.dist-info/METADATA b/third_party/python/six/six-1.16.0.dist-info/METADATA |
| 151 | similarity index 85% |
| 152 | rename from third_party/python/six/six-1.13.0.dist-info/METADATA |
| 153 | rename to third_party/python/six/six-1.16.0.dist-info/METADATA |
| 154 | index b0c8f51e1f366..6d7525c2ebcfe 100644 |
| 155 | --- a/third_party/python/six/six-1.13.0.dist-info/METADATA |
| 156 | +++ b/third_party/python/six/six-1.16.0.dist-info/METADATA |
| 157 | @@ -1,6 +1,6 @@ |
| 158 | Metadata-Version: 2.1 |
| 159 | Name: six |
| 160 | -Version: 1.13.0 |
| 161 | +Version: 1.16.0 |
| 162 | Summary: Python 2 and 3 compatibility utilities |
| 163 | Home-page: https://github.com/benjaminp/six |
| 164 | Author: Benjamin Peterson |
| 165 | @@ -14,7 +14,7 @@ Classifier: Intended Audience :: Developers |
| 166 | Classifier: License :: OSI Approved :: MIT License |
| 167 | Classifier: Topic :: Software Development :: Libraries |
| 168 | Classifier: Topic :: Utilities |
| 169 | -Requires-Python: >=2.6, !=3.0.*, !=3.1.* |
| 170 | +Requires-Python: >=2.7, !=3.0.*, !=3.1.*, !=3.2.* |
| 171 | |
| 172 | .. image:: https://img.shields.io/pypi/v/six.svg |
| 173 | :target: https://pypi.org/project/six/ |
| 174 | @@ -37,7 +37,7 @@ for smoothing over the differences between the Python versions with the goal of |
| 175 | writing Python code that is compatible on both Python versions. See the |
| 176 | documentation for more information on what is provided. |
| 177 | |
| 178 | -Six supports every Python version since 2.6. It is contained in only one Python |
| 179 | +Six supports Python 2.7 and 3.3+. It is contained in only one Python |
| 180 | file, so it can be easily copied into your project. (The copyright and license |
| 181 | notice must be retained.) |
| 182 | |
| 183 | @@ -46,7 +46,4 @@ Online documentation is at https://six.readthedocs.io/. |
| 184 | Bugs can be reported to https://github.com/benjaminp/six. The code can also |
| 185 | be found there. |
| 186 | |
| 187 | -For questions about six or porting in general, email the python-porting mailing |
| 188 | -list: https://mail.python.org/mailman/listinfo/python-porting |
| 189 | - |
| 190 | |
| 191 | diff --git a/third_party/python/six/six-1.16.0.dist-info/RECORD b/third_party/python/six/six-1.16.0.dist-info/RECORD |
| 192 | new file mode 100644 |
| 193 | index 0000000000000..8de4af79fae0b |
| 194 | --- /dev/null |
| 195 | +++ b/third_party/python/six/six-1.16.0.dist-info/RECORD |
| 196 | @@ -0,0 +1,6 @@ |
| 197 | +six.py,sha256=TOOfQi7nFGfMrIvtdr6wX4wyHH8M7aknmuLfo2cBBrM,34549 |
| 198 | +six-1.16.0.dist-info/LICENSE,sha256=i7hQxWWqOJ_cFvOkaWWtI9gq3_YPI5P8J2K2MYXo5sk,1066 |
| 199 | +six-1.16.0.dist-info/METADATA,sha256=VQcGIFCAEmfZcl77E5riPCN4v2TIsc_qtacnjxKHJoI,1795 |
| 200 | +six-1.16.0.dist-info/WHEEL,sha256=Z-nyYpwrcSqxfdux5Mbn_DQ525iP7J2DG3JgGvOYyTQ,110 |
| 201 | +six-1.16.0.dist-info/top_level.txt,sha256=_iVH_iYEtEXnD8nYGQYpYFUvkUW9sEO1GYbkeKSAais,4 |
| 202 | +six-1.16.0.dist-info/RECORD,, |
| 203 | diff --git a/third_party/python/urllib3/urllib3-1.26.0.dist-info/WHEEL b/third_party/python/six/six-1.16.0.dist-info/WHEEL |
| 204 | similarity index 70% |
| 205 | rename from third_party/python/urllib3/urllib3-1.26.0.dist-info/WHEEL |
| 206 | rename to third_party/python/six/six-1.16.0.dist-info/WHEEL |
| 207 | index 6d38aa0601b31..01b8fc7d4a10c 100644 |
| 208 | --- a/third_party/python/urllib3/urllib3-1.26.0.dist-info/WHEEL |
| 209 | +++ b/third_party/python/six/six-1.16.0.dist-info/WHEEL |
| 210 | @@ -1,5 +1,5 @@ |
| 211 | Wheel-Version: 1.0 |
| 212 | -Generator: bdist_wheel (0.35.1) |
| 213 | +Generator: bdist_wheel (0.36.2) |
| 214 | Root-Is-Purelib: true |
| 215 | Tag: py2-none-any |
| 216 | Tag: py3-none-any |
| 217 | diff --git a/third_party/python/six/six-1.13.0.dist-info/top_level.txt b/third_party/python/six/six-1.16.0.dist-info/top_level.txt |
| 218 | similarity index 100% |
| 219 | rename from third_party/python/six/six-1.13.0.dist-info/top_level.txt |
| 220 | rename to third_party/python/six/six-1.16.0.dist-info/top_level.txt |
| 221 | diff --git a/third_party/python/six/six.py b/third_party/python/six/six.py |
| 222 | index 357e624abc6c9..4e15675d8b5ca 100644 |
| 223 | --- a/third_party/python/six/six.py |
| 224 | +++ b/third_party/python/six/six.py |
| 225 | @@ -1,4 +1,4 @@ |
| 226 | -# Copyright (c) 2010-2019 Benjamin Peterson |
| 227 | +# Copyright (c) 2010-2020 Benjamin Peterson |
| 228 | # |
| 229 | # Permission is hereby granted, free of charge, to any person obtaining a copy |
| 230 | # of this software and associated documentation files (the "Software"), to deal |
| 231 | @@ -29,7 +29,7 @@ |
| 232 | import types |
| 233 | |
| 234 | __author__ = "Benjamin Peterson <benjamin@python.org>" |
| 235 | -__version__ = "1.13.0" |
| 236 | +__version__ = "1.16.0" |
| 237 | |
| 238 | |
| 239 | # Useful for very coarse version differentiation. |
| 240 | @@ -71,6 +71,11 @@ def __len__(self): |
| 241 | MAXSIZE = int((1 << 63) - 1) |
| 242 | del X |
| 243 | |
| 244 | +if PY34: |
| 245 | + from importlib.util import spec_from_loader |
| 246 | +else: |
| 247 | + spec_from_loader = None |
| 248 | + |
| 249 | |
| 250 | def _add_doc(func, doc): |
| 251 | """Add documentation to a function.""" |
| 252 | @@ -186,6 +191,11 @@ def find_module(self, fullname, path=None): |
| 253 | return self |
| 254 | return None |
| 255 | |
| 256 | + def find_spec(self, fullname, path, target=None): |
| 257 | + if fullname in self.known_modules: |
| 258 | + return spec_from_loader(fullname, self) |
| 259 | + return None |
| 260 | + |
| 261 | def __get_module(self, fullname): |
| 262 | try: |
| 263 | return self.known_modules[fullname] |
| 264 | @@ -223,6 +233,12 @@ def get_code(self, fullname): |
| 265 | return None |
| 266 | get_source = get_code # same as get_code |
| 267 | |
| 268 | + def create_module(self, spec): |
| 269 | + return self.load_module(spec.name) |
| 270 | + |
| 271 | + def exec_module(self, module): |
| 272 | + pass |
| 273 | + |
| 274 | _importer = _SixMetaPathImporter(__name__) |
| 275 | |
| 276 | |
| 277 | @@ -259,7 +275,7 @@ class _MovedItems(_LazyModule): |
| 278 | MovedModule("copyreg", "copy_reg"), |
| 279 | MovedModule("dbm_gnu", "gdbm", "dbm.gnu"), |
| 280 | MovedModule("dbm_ndbm", "dbm", "dbm.ndbm"), |
| 281 | - MovedModule("_dummy_thread", "dummy_thread", "_dummy_thread"), |
| 282 | + MovedModule("_dummy_thread", "dummy_thread", "_dummy_thread" if sys.version_info < (3, 9) else "_thread"), |
| 283 | MovedModule("http_cookiejar", "cookielib", "http.cookiejar"), |
| 284 | MovedModule("http_cookies", "Cookie", "http.cookies"), |
| 285 | MovedModule("html_entities", "htmlentitydefs", "html.entities"), |
| 286 | @@ -644,9 +660,11 @@ def u(s): |
| 287 | if sys.version_info[1] <= 1: |
| 288 | _assertRaisesRegex = "assertRaisesRegexp" |
| 289 | _assertRegex = "assertRegexpMatches" |
| 290 | + _assertNotRegex = "assertNotRegexpMatches" |
| 291 | else: |
| 292 | _assertRaisesRegex = "assertRaisesRegex" |
| 293 | _assertRegex = "assertRegex" |
| 294 | + _assertNotRegex = "assertNotRegex" |
| 295 | else: |
| 296 | def b(s): |
| 297 | return s |
| 298 | @@ -668,6 +686,7 @@ def indexbytes(buf, i): |
| 299 | _assertCountEqual = "assertItemsEqual" |
| 300 | _assertRaisesRegex = "assertRaisesRegexp" |
| 301 | _assertRegex = "assertRegexpMatches" |
| 302 | + _assertNotRegex = "assertNotRegexpMatches" |
| 303 | _add_doc(b, """Byte literal""") |
| 304 | _add_doc(u, """Text literal""") |
| 305 | |
| 306 | @@ -684,6 +703,10 @@ def assertRegex(self, *args, **kwargs): |
| 307 | return getattr(self, _assertRegex)(*args, **kwargs) |
| 308 | |
| 309 | |
| 310 | +def assertNotRegex(self, *args, **kwargs): |
| 311 | + return getattr(self, _assertNotRegex)(*args, **kwargs) |
| 312 | + |
| 313 | + |
| 314 | if PY3: |
| 315 | exec_ = getattr(moves.builtins, "exec") |
| 316 | |
| 317 | @@ -719,16 +742,7 @@ def exec_(_code_, _globs_=None, _locs_=None): |
| 318 | """) |
| 319 | |
| 320 | |
| 321 | -if sys.version_info[:2] == (3, 2): |
| 322 | - exec_("""def raise_from(value, from_value): |
| 323 | - try: |
| 324 | - if from_value is None: |
| 325 | - raise value |
| 326 | - raise value from from_value |
| 327 | - finally: |
| 328 | - value = None |
| 329 | -""") |
| 330 | -elif sys.version_info[:2] > (3, 2): |
| 331 | +if sys.version_info[:2] > (3,): |
| 332 | exec_("""def raise_from(value, from_value): |
| 333 | try: |
| 334 | raise value from from_value |
| 335 | @@ -808,13 +822,33 @@ def print_(*args, **kwargs): |
| 336 | _add_doc(reraise, """Reraise an exception.""") |
| 337 | |
| 338 | if sys.version_info[0:2] < (3, 4): |
| 339 | + # This does exactly the same what the :func:`py3:functools.update_wrapper` |
| 340 | + # function does on Python versions after 3.2. It sets the ``__wrapped__`` |
| 341 | + # attribute on ``wrapper`` object and it doesn't raise an error if any of |
| 342 | + # the attributes mentioned in ``assigned`` and ``updated`` are missing on |
| 343 | + # ``wrapped`` object. |
| 344 | + def _update_wrapper(wrapper, wrapped, |
| 345 | + assigned=functools.WRAPPER_ASSIGNMENTS, |
| 346 | + updated=functools.WRAPPER_UPDATES): |
| 347 | + for attr in assigned: |
| 348 | + try: |
| 349 | + value = getattr(wrapped, attr) |
| 350 | + except AttributeError: |
| 351 | + continue |
| 352 | + else: |
| 353 | + setattr(wrapper, attr, value) |
| 354 | + for attr in updated: |
| 355 | + getattr(wrapper, attr).update(getattr(wrapped, attr, {})) |
| 356 | + wrapper.__wrapped__ = wrapped |
| 357 | + return wrapper |
| 358 | + _update_wrapper.__doc__ = functools.update_wrapper.__doc__ |
| 359 | + |
| 360 | def wraps(wrapped, assigned=functools.WRAPPER_ASSIGNMENTS, |
| 361 | updated=functools.WRAPPER_UPDATES): |
| 362 | - def wrapper(f): |
| 363 | - f = functools.wraps(wrapped, assigned, updated)(f) |
| 364 | - f.__wrapped__ = wrapped |
| 365 | - return f |
| 366 | - return wrapper |
| 367 | + return functools.partial(_update_wrapper, wrapped=wrapped, |
| 368 | + assigned=assigned, updated=updated) |
| 369 | + wraps.__doc__ = functools.wraps.__doc__ |
| 370 | + |
| 371 | else: |
| 372 | wraps = functools.wraps |
| 373 | |
| 374 | @@ -872,12 +906,11 @@ def ensure_binary(s, encoding='utf-8', errors='strict'): |
| 375 | - `str` -> encoded to `bytes` |
| 376 | - `bytes` -> `bytes` |
| 377 | """ |
| 378 | + if isinstance(s, binary_type): |
| 379 | + return s |
| 380 | if isinstance(s, text_type): |
| 381 | return s.encode(encoding, errors) |
| 382 | - elif isinstance(s, binary_type): |
| 383 | - return s |
| 384 | - else: |
| 385 | - raise TypeError("not expecting type '%s'" % type(s)) |
| 386 | + raise TypeError("not expecting type '%s'" % type(s)) |
| 387 | |
| 388 | |
| 389 | def ensure_str(s, encoding='utf-8', errors='strict'): |
| 390 | @@ -891,12 +924,15 @@ def ensure_str(s, encoding='utf-8', errors='strict'): |
| 391 | - `str` -> `str` |
| 392 | - `bytes` -> decoded to `str` |
| 393 | """ |
| 394 | - if not isinstance(s, (text_type, binary_type)): |
| 395 | - raise TypeError("not expecting type '%s'" % type(s)) |
| 396 | + # Optimization: Fast return for the common case. |
| 397 | + if type(s) is str: |
| 398 | + return s |
| 399 | if PY2 and isinstance(s, text_type): |
| 400 | - s = s.encode(encoding, errors) |
| 401 | + return s.encode(encoding, errors) |
| 402 | elif PY3 and isinstance(s, binary_type): |
| 403 | - s = s.decode(encoding, errors) |
| 404 | + return s.decode(encoding, errors) |
| 405 | + elif not isinstance(s, (text_type, binary_type)): |
| 406 | + raise TypeError("not expecting type '%s'" % type(s)) |
| 407 | return s |
| 408 | |
| 409 | |
| 410 | @@ -919,10 +955,9 @@ def ensure_text(s, encoding='utf-8', errors='strict'): |
| 411 | raise TypeError("not expecting type '%s'" % type(s)) |
| 412 | |
| 413 | |
| 414 | - |
| 415 | def python_2_unicode_compatible(klass): |
| 416 | """ |
| 417 | - A decorator that defines __unicode__ and __str__ methods under Python 2. |
| 418 | + A class decorator that defines __unicode__ and __str__ methods under Python 2. |
| 419 | Under Python 3 it does nothing. |
| 420 | |
| 421 | To support Python 2 and 3 with a single code base, define a __str__ method |
| 422 | diff --git a/third_party/python/urllib3/urllib3-1.26.0.dist-info/RECORD b/third_party/python/urllib3/urllib3-1.26.0.dist-info/RECORD |
| 423 | deleted file mode 100644 |
| 424 | index ec9088a111a41..0000000000000 |
| 425 | --- a/third_party/python/urllib3/urllib3-1.26.0.dist-info/RECORD |
| 426 | +++ /dev/null |
| 427 | @@ -1,44 +0,0 @@ |
| 428 | -urllib3/__init__.py,sha256=j3yzHIbmW7CS-IKQJ9-PPQf_YKO8EOAey_rMW0UR7us,2763 |
| 429 | -urllib3/_collections.py,sha256=Rp1mVyBgc_UlAcp6M3at1skJBXR5J43NawRTvW2g_XY,10811 |
| 430 | -urllib3/_version.py,sha256=H0vLQ8PY350EPZlZQa8ri0tEjVS-xhGdQOHcU360-0A,63 |
| 431 | -urllib3/connection.py,sha256=BdaUSNpGzO0zq28i9MhOXb6QZspeVdVrYtjnkk2Eqg4,18396 |
| 432 | -urllib3/connectionpool.py,sha256=IKoeuJZY9YAYm0GK4q-MXAhyXW0M_FnvabYaNsDIR-E,37133 |
| 433 | -urllib3/exceptions.py,sha256=lNrKC5J8zeBXIu9SSKSNb7cLi8iXl9ARu9DHD2SflZM,7810 |
| 434 | -urllib3/fields.py,sha256=kvLDCg_JmH1lLjUUEY_FLS8UhY7hBvDPuVETbY8mdrM,8579 |
| 435 | -urllib3/filepost.py,sha256=5b_qqgRHVlL7uLtdAYBzBh-GHmU5AfJVt_2N0XS3PeY,2440 |
| 436 | -urllib3/poolmanager.py,sha256=whzlX6UTEgODMOCy0ZDMUONRBCz5wyIM8Z9opXAY-Lk,19763 |
| 437 | -urllib3/request.py,sha256=ZFSIqX0C6WizixecChZ3_okyu7BEv0lZu1VT0s6h4SM,5985 |
| 438 | -urllib3/response.py,sha256=hGhGBh7TkEkh_IQg5C1W_xuPNrgIKv5BUXPyE-q0LuE,28203 |
| 439 | -urllib3/contrib/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0 |
| 440 | -urllib3/contrib/_appengine_environ.py,sha256=bDbyOEhW2CKLJcQqAKAyrEHN-aklsyHFKq6vF8ZFsmk,957 |
| 441 | -urllib3/contrib/appengine.py,sha256=7Pxb0tKfDB_LTGPERiswH0qomhDoUUOo5kwybAKLQyE,11010 |
| 442 | -urllib3/contrib/ntlmpool.py,sha256=6I95h1_71fzxmoMSNtY0gB8lnyCoVtP_DpqFGj14fdU,4160 |
| 443 | -urllib3/contrib/pyopenssl.py,sha256=vgh6j52w9xgwq-3R2kfB5M2JblQATJfKAK3lIAc1kSg,16778 |
| 444 | -urllib3/contrib/securetransport.py,sha256=KxGPZk8d4YepWm7Rc-SBt1XrzIfnLKc8JkUVV75XzgE,34286 |
| 445 | -urllib3/contrib/socks.py,sha256=DcRjM2l0rQMIyhYrN6r-tnVkY6ZTDxHJlM8_usAkGCA,7097 |
| 446 | -urllib3/contrib/_securetransport/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0 |
| 447 | -urllib3/contrib/_securetransport/bindings.py,sha256=E1_7ScsgOchfxneozbAueK7ziCwF35fna4DuDCYJ9_o,17637 |
| 448 | -urllib3/contrib/_securetransport/low_level.py,sha256=lgIdsSycqfB0Xm5BiJzXGeIKT7ybCQMFPJAgkcwPa1s,13908 |
| 449 | -urllib3/packages/__init__.py,sha256=h4BLhD4tLaBx1adaDtKXfupsgqY0wWLXb_f1_yVlV6A,108 |
| 450 | -urllib3/packages/six.py,sha256=adx4z-eM_D0Vvu0IIqVzFACQ_ux9l64y7DkSEfbxCDs,32536 |
| 451 | -urllib3/packages/backports/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0 |
| 452 | -urllib3/packages/backports/makefile.py,sha256=nbzt3i0agPVP07jqqgjhaYjMmuAi_W5E0EywZivVO8E,1417 |
| 453 | -urllib3/packages/ssl_match_hostname/__init__.py,sha256=zppezdEQdpGsYerI6mV6MfUYy495JV4mcOWC_GgbljU,757 |
| 454 | -urllib3/packages/ssl_match_hostname/_implementation.py,sha256=6dZ-q074g7XhsJ27MFCgkct8iVNZB3sMZvKhf-KUVy0,5679 |
| 455 | -urllib3/util/__init__.py,sha256=JEmSmmqqLyaw8P51gUImZh8Gwg9i1zSe-DoqAitn2nc,1155 |
| 456 | -urllib3/util/connection.py,sha256=21B-LX0c8fkxPDssyHCaK0pCnmrKmhltg5EoouHiAPU,4910 |
| 457 | -urllib3/util/proxy.py,sha256=FGipAEnvZteyldXNjce4DEB7YzwU-a5lep8y5S0qHQg,1604 |
| 458 | -urllib3/util/queue.py,sha256=nRgX8_eX-_VkvxoX096QWoz8Ps0QHUAExILCY_7PncM,498 |
| 459 | -urllib3/util/request.py,sha256=NnzaEKQ1Pauw5MFMV6HmgEMHITf0Aua9fQuzi2uZzGc,4123 |
| 460 | -urllib3/util/response.py,sha256=GJpg3Egi9qaJXRwBh5wv-MNuRWan5BIu40oReoxWP28,3510 |
| 461 | -urllib3/util/retry.py,sha256=tn168HDMUynFmXRP-uVaLRUOlbTEJikoB1RuZdwfCes,21366 |
| 462 | -urllib3/util/ssl_.py,sha256=cUsmU604z2zAOZcaXDpINXOokQ1RtlJMe96TBDkaJp0,16199 |
| 463 | -urllib3/util/ssltransport.py,sha256=IvGQvs9YWkf4jzfqVjTu_UWjwAUgPn5ActajW8VLz6A,6908 |
| 464 | -urllib3/util/timeout.py,sha256=QSbBUNOB9yh6AnDn61SrLQ0hg5oz0I9-uXEG91AJuIg,10003 |
| 465 | -urllib3/util/url.py,sha256=LWfLSlI4l2FmUMKfCkElCaW10-0N-sJDT9bxaDZJkjs,13964 |
| 466 | -urllib3/util/wait.py,sha256=3MUKRSAUJDB2tgco7qRUskW0zXGAWYvRRE4Q1_6xlLs,5404 |
| 467 | -urllib3-1.26.0.dist-info/LICENSE.txt,sha256=w3vxhuJ8-dvpYZ5V7f486nswCRzrPaY8fay-Dm13kHs,1115 |
| 468 | -urllib3-1.26.0.dist-info/METADATA,sha256=Wghdt6nLf9HfZHhWj8Dpgz4n9vGRqXYhdIwJRPgki6M,42629 |
| 469 | -urllib3-1.26.0.dist-info/WHEEL,sha256=ADKeyaGyKF5DwBNE0sRE5pvW-bSkFMJfBuhzZ3rceP4,110 |
| 470 | -urllib3-1.26.0.dist-info/top_level.txt,sha256=EMiXL2sKrTcmrMxIHTqdc3ET54pQI2Y072LexFEemvo,8 |
| 471 | -urllib3-1.26.0.dist-info/RECORD,, |
| 472 | diff --git a/third_party/python/urllib3/urllib3-1.26.0.dist-info/LICENSE.txt b/third_party/python/urllib3/urllib3-1.26.17.dist-info/LICENSE.txt |
| 473 | similarity index 100% |
| 474 | rename from third_party/python/urllib3/urllib3-1.26.0.dist-info/LICENSE.txt |
| 475 | rename to third_party/python/urllib3/urllib3-1.26.17.dist-info/LICENSE.txt |
| 476 | diff --git a/third_party/python/urllib3/urllib3-1.26.0.dist-info/METADATA b/third_party/python/urllib3/urllib3-1.26.17.dist-info/METADATA |
| 477 | similarity index 86% |
| 478 | rename from third_party/python/urllib3/urllib3-1.26.0.dist-info/METADATA |
| 479 | rename to third_party/python/urllib3/urllib3-1.26.17.dist-info/METADATA |
| 480 | index 39869aafada8a..9493faee66c01 100644 |
| 481 | --- a/third_party/python/urllib3/urllib3-1.26.0.dist-info/METADATA |
| 482 | +++ b/third_party/python/urllib3/urllib3-1.26.17.dist-info/METADATA |
| 483 | @@ -1,6 +1,6 @@ |
| 484 | Metadata-Version: 2.1 |
| 485 | Name: urllib3 |
| 486 | -Version: 1.26.0 |
| 487 | +Version: 1.26.17 |
| 488 | Summary: HTTP library with thread-safe connection pooling, file post, and more. |
| 489 | Home-page: https://urllib3.readthedocs.io/ |
| 490 | Author: Andrey Petrov |
| 491 | @@ -10,7 +10,6 @@ Project-URL: Documentation, https://urllib3.readthedocs.io/ |
| 492 | Project-URL: Code, https://github.com/urllib3/urllib3 |
| 493 | Project-URL: Issue tracker, https://github.com/urllib3/urllib3/issues |
| 494 | Keywords: urllib httplib threadsafe filepost http https ssl pooling |
| 495 | -Platform: UNKNOWN |
| 496 | Classifier: Environment :: Web Environment |
| 497 | Classifier: Intended Audience :: Developers |
| 498 | Classifier: License :: OSI Approved :: MIT License |
| 499 | @@ -19,27 +18,33 @@ Classifier: Programming Language :: Python |
| 500 | Classifier: Programming Language :: Python :: 2 |
| 501 | Classifier: Programming Language :: Python :: 2.7 |
| 502 | Classifier: Programming Language :: Python :: 3 |
| 503 | -Classifier: Programming Language :: Python :: 3.5 |
| 504 | Classifier: Programming Language :: Python :: 3.6 |
| 505 | Classifier: Programming Language :: Python :: 3.7 |
| 506 | Classifier: Programming Language :: Python :: 3.8 |
| 507 | Classifier: Programming Language :: Python :: 3.9 |
| 508 | +Classifier: Programming Language :: Python :: 3.10 |
| 509 | +Classifier: Programming Language :: Python :: 3.11 |
| 510 | Classifier: Programming Language :: Python :: Implementation :: CPython |
| 511 | Classifier: Programming Language :: Python :: Implementation :: PyPy |
| 512 | Classifier: Topic :: Internet :: WWW/HTTP |
| 513 | Classifier: Topic :: Software Development :: Libraries |
| 514 | -Requires-Python: >=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, <4 |
| 515 | +Requires-Python: >=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, !=3.5.* |
| 516 | Description-Content-Type: text/x-rst |
| 517 | +License-File: LICENSE.txt |
| 518 | Provides-Extra: brotli |
| 519 | -Requires-Dist: brotlipy (>=0.6.0) ; extra == 'brotli' |
| 520 | +Requires-Dist: brotlicffi >=0.8.0 ; ((os_name != "nt" or python_version >= "3") and platform_python_implementation != "CPython") and extra == 'brotli' |
| 521 | +Requires-Dist: brotli ==1.0.9 ; (os_name != "nt" and python_version < "3" and platform_python_implementation == "CPython") and extra == 'brotli' |
| 522 | +Requires-Dist: brotlipy >=0.6.0 ; (os_name == "nt" and python_version < "3") and extra == 'brotli' |
| 523 | +Requires-Dist: brotli >=1.0.9 ; (python_version >= "3" and platform_python_implementation == "CPython") and extra == 'brotli' |
| 524 | Provides-Extra: secure |
| 525 | -Requires-Dist: pyOpenSSL (>=0.14) ; extra == 'secure' |
| 526 | -Requires-Dist: cryptography (>=1.3.4) ; extra == 'secure' |
| 527 | -Requires-Dist: idna (>=2.0.0) ; extra == 'secure' |
| 528 | +Requires-Dist: pyOpenSSL >=0.14 ; extra == 'secure' |
| 529 | +Requires-Dist: cryptography >=1.3.4 ; extra == 'secure' |
| 530 | +Requires-Dist: idna >=2.0.0 ; extra == 'secure' |
| 531 | Requires-Dist: certifi ; extra == 'secure' |
| 532 | +Requires-Dist: urllib3-secure-extra ; extra == 'secure' |
| 533 | Requires-Dist: ipaddress ; (python_version == "2.7") and extra == 'secure' |
| 534 | Provides-Extra: socks |
| 535 | -Requires-Dist: PySocks (!=1.5.7,<2.0,>=1.5.6) ; extra == 'socks' |
| 536 | +Requires-Dist: PySocks !=1.5.7,<2.0,>=1.5.6 ; extra == 'socks' |
| 537 | |
| 538 | |
| 539 | urllib3 is a powerful, *user-friendly* HTTP client for Python. Much of the |
| 540 | @@ -78,8 +83,10 @@ urllib3 can be installed with `pip <https://pip.pypa.io>`_:: |
| 541 | |
| 542 | Alternatively, you can grab the latest source code from `GitHub <https://github.com/urllib3/urllib3>`_:: |
| 543 | |
| 544 | - $ git clone git://github.com/urllib3/urllib3.git |
| 545 | - $ python setup.py install |
| 546 | + $ git clone https://github.com/urllib3/urllib3.git |
| 547 | + $ cd urllib3 |
| 548 | + $ git checkout 1.26.x |
| 549 | + $ pip install . |
| 550 | |
| 551 | |
| 552 | Documentation |
| 553 | @@ -148,6 +155,152 @@ For Enterprise |
| 554 | Changes |
| 555 | ======= |
| 556 | |
| 557 | +1.26.17 (2023-10-02) |
| 558 | +-------------------- |
| 559 | + |
| 560 | +* Added the ``Cookie`` header to the list of headers to strip from requests when redirecting to a different host. As before, different headers can be set via ``Retry.remove_headers_on_redirect``. |
| 561 | + |
| 562 | + |
| 563 | +1.26.16 (2023-05-23) |
| 564 | +-------------------- |
| 565 | + |
| 566 | +* Fixed thread-safety issue where accessing a ``PoolManager`` with many distinct origins |
| 567 | + would cause connection pools to be closed while requests are in progress (`#2954 <https://github.com/urllib3/urllib3/pull/2954>`_) |
| 568 | + |
| 569 | + |
| 570 | +1.26.15 (2023-03-10) |
| 571 | +-------------------- |
| 572 | + |
| 573 | +* Fix socket timeout value when ``HTTPConnection`` is reused (`#2645 <https://github.com/urllib3/urllib3/issues/2645>`__) |
| 574 | +* Remove "!" character from the unreserved characters in IPv6 Zone ID parsing |
| 575 | + (`#2899 <https://github.com/urllib3/urllib3/issues/2899>`__) |
| 576 | +* Fix IDNA handling of '\x80' byte (`#2901 <https://github.com/urllib3/urllib3/issues/2901>`__) |
| 577 | + |
| 578 | +1.26.14 (2023-01-11) |
| 579 | +-------------------- |
| 580 | + |
| 581 | +* Fixed parsing of port 0 (zero) returning None, instead of 0. (`#2850 <https://github.com/urllib3/urllib3/issues/2850>`__) |
| 582 | +* Removed deprecated getheaders() calls in contrib module. |
| 583 | + |
| 584 | +1.26.13 (2022-11-23) |
| 585 | +-------------------- |
| 586 | + |
| 587 | +* Deprecated the ``HTTPResponse.getheaders()`` and ``HTTPResponse.getheader()`` methods. |
| 588 | +* Fixed an issue where parsing a URL with leading zeroes in the port would be rejected |
| 589 | + even when the port number after removing the zeroes was valid. |
| 590 | +* Fixed a deprecation warning when using cryptography v39.0.0. |
| 591 | +* Removed the ``<4`` in the ``Requires-Python`` packaging metadata field. |
| 592 | + |
| 593 | + |
| 594 | +1.26.12 (2022-08-22) |
| 595 | +-------------------- |
| 596 | + |
| 597 | +* Deprecated the `urllib3[secure]` extra and the `urllib3.contrib.pyopenssl` module. |
| 598 | + Both will be removed in v2.x. See this `GitHub issue <https://github.com/urllib3/urllib3/issues/2680>`_ |
| 599 | + for justification and info on how to migrate. |
| 600 | + |
| 601 | + |
| 602 | +1.26.11 (2022-07-25) |
| 603 | +-------------------- |
| 604 | + |
| 605 | +* Fixed an issue where reading more than 2 GiB in a call to ``HTTPResponse.read`` would |
| 606 | + raise an ``OverflowError`` on Python 3.9 and earlier. |
| 607 | + |
| 608 | + |
| 609 | +1.26.10 (2022-07-07) |
| 610 | +-------------------- |
| 611 | + |
| 612 | +* Removed support for Python 3.5 |
| 613 | +* Fixed an issue where a ``ProxyError`` recommending configuring the proxy as HTTP |
| 614 | + instead of HTTPS could appear even when an HTTPS proxy wasn't configured. |
| 615 | + |
| 616 | + |
| 617 | +1.26.9 (2022-03-16) |
| 618 | +------------------- |
| 619 | + |
| 620 | +* Changed ``urllib3[brotli]`` extra to favor installing Brotli libraries that are still |
| 621 | + receiving updates like ``brotli`` and ``brotlicffi`` instead of ``brotlipy``. |
| 622 | + This change does not impact behavior of urllib3, only which dependencies are installed. |
| 623 | +* Fixed a socket leaking when ``HTTPSConnection.connect()`` raises an exception. |
| 624 | +* Fixed ``server_hostname`` being forwarded from ``PoolManager`` to ``HTTPConnectionPool`` |
| 625 | + when requesting an HTTP URL. Should only be forwarded when requesting an HTTPS URL. |
| 626 | + |
| 627 | + |
| 628 | +1.26.8 (2022-01-07) |
| 629 | +------------------- |
| 630 | + |
| 631 | +* Added extra message to ``urllib3.exceptions.ProxyError`` when urllib3 detects that |
| 632 | + a proxy is configured to use HTTPS but the proxy itself appears to only use HTTP. |
| 633 | +* Added a mention of the size of the connection pool when discarding a connection due to the pool being full. |
| 634 | +* Added explicit support for Python 3.11. |
| 635 | +* Deprecated the ``Retry.MAX_BACKOFF`` class property in favor of ``Retry.DEFAULT_MAX_BACKOFF`` |
| 636 | + to better match the rest of the default parameter names. ``Retry.MAX_BACKOFF`` is removed in v2.0. |
| 637 | +* Changed location of the vendored ``ssl.match_hostname`` function from ``urllib3.packages.ssl_match_hostname`` |
| 638 | + to ``urllib3.util.ssl_match_hostname`` to ensure Python 3.10+ compatibility after being repackaged |
| 639 | + by downstream distributors. |
| 640 | +* Fixed absolute imports, all imports are now relative. |
| 641 | + |
| 642 | + |
| 643 | +1.26.7 (2021-09-22) |
| 644 | +------------------- |
| 645 | + |
| 646 | +* Fixed a bug with HTTPS hostname verification involving IP addresses and lack |
| 647 | + of SNI. (Issue #2400) |
| 648 | +* Fixed a bug where IPv6 braces weren't stripped during certificate hostname |
| 649 | + matching. (Issue #2240) |
| 650 | + |
| 651 | + |
| 652 | +1.26.6 (2021-06-25) |
| 653 | +------------------- |
| 654 | + |
| 655 | +* Deprecated the ``urllib3.contrib.ntlmpool`` module. urllib3 is not able to support |
| 656 | + it properly due to `reasons listed in this issue <https://github.com/urllib3/urllib3/issues/2282>`_. |
| 657 | + If you are a user of this module please leave a comment. |
| 658 | +* Changed ``HTTPConnection.request_chunked()`` to not erroneously emit multiple |
| 659 | + ``Transfer-Encoding`` headers in the case that one is already specified. |
| 660 | +* Fixed typo in deprecation message to recommend ``Retry.DEFAULT_ALLOWED_METHODS``. |
| 661 | + |
| 662 | + |
| 663 | +1.26.5 (2021-05-26) |
| 664 | +------------------- |
| 665 | + |
| 666 | +* Fixed deprecation warnings emitted in Python 3.10. |
| 667 | +* Updated vendored ``six`` library to 1.16.0. |
| 668 | +* Improved performance of URL parser when splitting |
| 669 | + the authority component. |
| 670 | + |
| 671 | + |
| 672 | +1.26.4 (2021-03-15) |
| 673 | +------------------- |
| 674 | + |
| 675 | +* Changed behavior of the default ``SSLContext`` when connecting to HTTPS proxy |
| 676 | + during HTTPS requests. The default ``SSLContext`` now sets ``check_hostname=True``. |
| 677 | + |
| 678 | + |
| 679 | +1.26.3 (2021-01-26) |
| 680 | +------------------- |
| 681 | + |
| 682 | +* Fixed bytes and string comparison issue with headers (Pull #2141) |
| 683 | + |
| 684 | +* Changed ``ProxySchemeUnknown`` error message to be |
| 685 | + more actionable if the user supplies a proxy URL without |
| 686 | + a scheme. (Pull #2107) |
| 687 | + |
| 688 | + |
| 689 | +1.26.2 (2020-11-12) |
| 690 | +------------------- |
| 691 | + |
| 692 | +* Fixed an issue where ``wrap_socket`` and ``CERT_REQUIRED`` wouldn't |
| 693 | + be imported properly on Python 2.7.8 and earlier (Pull #2052) |
| 694 | + |
| 695 | + |
| 696 | +1.26.1 (2020-11-11) |
| 697 | +------------------- |
| 698 | + |
| 699 | +* Fixed an issue where two ``User-Agent`` headers would be sent if a |
| 700 | + ``User-Agent`` header key is passed as ``bytes`` (Pull #2047) |
| 701 | + |
| 702 | + |
| 703 | 1.26.0 (2020-11-10) |
| 704 | ------------------- |
| 705 | |
| 706 | @@ -1331,5 +1484,3 @@ Changes |
| 707 | ---------------- |
| 708 | |
| 709 | * First release. |
| 710 | - |
| 711 | - |
| 712 | diff --git a/third_party/python/urllib3/urllib3-1.26.17.dist-info/RECORD b/third_party/python/urllib3/urllib3-1.26.17.dist-info/RECORD |
| 713 | new file mode 100644 |
| 714 | index 0000000000000..1afc6580589c0 |
| 715 | --- /dev/null |
| 716 | +++ b/third_party/python/urllib3/urllib3-1.26.17.dist-info/RECORD |
| 717 | @@ -0,0 +1,44 @@ |
| 718 | +urllib3/__init__.py,sha256=iXLcYiJySn0GNbWOOZDDApgBL1JgP44EZ8i1760S8Mc,3333 |
| 719 | +urllib3/_collections.py,sha256=Rp1mVyBgc_UlAcp6M3at1skJBXR5J43NawRTvW2g_XY,10811 |
| 720 | +urllib3/_version.py,sha256=azoM7M7BUADl2kBhMVR6PPf2GhBDI90me1fcnzTwdcw,64 |
| 721 | +urllib3/connection.py,sha256=92k9td_y4PEiTIjNufCUa1NzMB3J3w0LEdyokYgXnW8,20300 |
| 722 | +urllib3/connectionpool.py,sha256=ItVDasDnPRPP9R8bNxY7tPBlC724nJ9nlxVgXG_SLbI,39990 |
| 723 | +urllib3/exceptions.py,sha256=0Mnno3KHTNfXRfY7638NufOPkUb6mXOm-Lqj-4x2w8A,8217 |
| 724 | +urllib3/fields.py,sha256=kvLDCg_JmH1lLjUUEY_FLS8UhY7hBvDPuVETbY8mdrM,8579 |
| 725 | +urllib3/filepost.py,sha256=5b_qqgRHVlL7uLtdAYBzBh-GHmU5AfJVt_2N0XS3PeY,2440 |
| 726 | +urllib3/poolmanager.py,sha256=0i8cJgrqupza67IBPZ_u9jXvnSxr5UBlVEiUqdkPtYI,19752 |
| 727 | +urllib3/request.py,sha256=YTWFNr7QIwh7E1W9dde9LM77v2VWTJ5V78XuTTw7D1A,6691 |
| 728 | +urllib3/response.py,sha256=UPgLmnHj4z71ZnH8ivYOyncATifTOw9FQukUqDnckCc,30761 |
| 729 | +urllib3/contrib/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0 |
| 730 | +urllib3/contrib/_appengine_environ.py,sha256=bDbyOEhW2CKLJcQqAKAyrEHN-aklsyHFKq6vF8ZFsmk,957 |
| 731 | +urllib3/contrib/appengine.py,sha256=6IBW6lPOoVUxASPwtn6IH1AATe5DK3lLJCfwyWlLKAE,11012 |
| 732 | +urllib3/contrib/ntlmpool.py,sha256=NlfkW7WMdW8ziqudopjHoW299og1BTWi0IeIibquFwk,4528 |
| 733 | +urllib3/contrib/pyopenssl.py,sha256=4AJAlo9NmjWofY4dJwRa4kbZuRuHfNJxu8Pv6yQk1ss,17055 |
| 734 | +urllib3/contrib/securetransport.py,sha256=QOhVbWrFQTKbmV-vtyG69amekkKVxXkdjk9oymaO0Ag,34416 |
| 735 | +urllib3/contrib/socks.py,sha256=aRi9eWXo9ZEb95XUxef4Z21CFlnnjbEiAo9HOseoMt4,7097 |
| 736 | +urllib3/contrib/_securetransport/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0 |
| 737 | +urllib3/contrib/_securetransport/bindings.py,sha256=4Xk64qIkPBt09A5q-RIFUuDhNc9mXilVapm7WnYnzRw,17632 |
| 738 | +urllib3/contrib/_securetransport/low_level.py,sha256=B2JBB2_NRP02xK6DCa1Pa9IuxrPwxzDzZbixQkb7U9M,13922 |
| 739 | +urllib3/packages/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0 |
| 740 | +urllib3/packages/six.py,sha256=b9LM0wBXv7E7SrbCjAm4wwN-hrH-iNxv18LgWNMMKPo,34665 |
| 741 | +urllib3/packages/backports/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0 |
| 742 | +urllib3/packages/backports/makefile.py,sha256=nbzt3i0agPVP07jqqgjhaYjMmuAi_W5E0EywZivVO8E,1417 |
| 743 | +urllib3/packages/backports/weakref_finalize.py,sha256=tRCal5OAhNSRyb0DhHp-38AtIlCsRP8BxF3NX-6rqIA,5343 |
| 744 | +urllib3/util/__init__.py,sha256=JEmSmmqqLyaw8P51gUImZh8Gwg9i1zSe-DoqAitn2nc,1155 |
| 745 | +urllib3/util/connection.py,sha256=5Lx2B1PW29KxBn2T0xkN1CBgRBa3gGVJBKoQoRogEVk,4901 |
| 746 | +urllib3/util/proxy.py,sha256=zUvPPCJrp6dOF0N4GAVbOcl6o-4uXKSrGiTkkr5vUS4,1605 |
| 747 | +urllib3/util/queue.py,sha256=nRgX8_eX-_VkvxoX096QWoz8Ps0QHUAExILCY_7PncM,498 |
| 748 | +urllib3/util/request.py,sha256=fWiAaa8pwdLLIqoTLBxCC2e4ed80muzKU3e3HWWTzFQ,4225 |
| 749 | +urllib3/util/response.py,sha256=GJpg3Egi9qaJXRwBh5wv-MNuRWan5BIu40oReoxWP28,3510 |
| 750 | +urllib3/util/retry.py,sha256=Z6WEf518eTOXP5jr5QSQ9gqJI0DVYt3Xs3EKnYaTmus,22013 |
| 751 | +urllib3/util/ssl_.py,sha256=c0sYiSC6272r6uPkxQpo5rYPP9QC1eR6oI7004gYqZo,17165 |
| 752 | +urllib3/util/ssl_match_hostname.py,sha256=Ir4cZVEjmAk8gUAIHWSi7wtOO83UCYABY2xFD1Ql_WA,5758 |
| 753 | +urllib3/util/ssltransport.py,sha256=NA-u5rMTrDFDFC8QzRKUEKMG0561hOD4qBTr3Z4pv6E,6895 |
| 754 | +urllib3/util/timeout.py,sha256=cwq4dMk87mJHSBktK1miYJ-85G-3T3RmT20v7SFCpno,10168 |
| 755 | +urllib3/util/url.py,sha256=kMxL1k0d-aQm_iZDw_zMmnyYyjrIA_DbsMy3cm3V55M,14279 |
| 756 | +urllib3/util/wait.py,sha256=fOX0_faozG2P7iVojQoE1mbydweNyTcm-hXEfFrTtLI,5403 |
| 757 | +urllib3-1.26.17.dist-info/LICENSE.txt,sha256=w3vxhuJ8-dvpYZ5V7f486nswCRzrPaY8fay-Dm13kHs,1115 |
| 758 | +urllib3-1.26.17.dist-info/METADATA,sha256=swEiQKmb2m5Vl4fygmy4aLSzZjxDjD8q2-_XzuhO9pA,48743 |
| 759 | +urllib3-1.26.17.dist-info/WHEEL,sha256=iYlv5fX357PQyRT2o6tw1bN-YcKFFHKqB_LwHO5wP-g,110 |
| 760 | +urllib3-1.26.17.dist-info/top_level.txt,sha256=EMiXL2sKrTcmrMxIHTqdc3ET54pQI2Y072LexFEemvo,8 |
| 761 | +urllib3-1.26.17.dist-info/RECORD,, |
| 762 | diff --git a/third_party/python/six/six-1.13.0.dist-info/WHEEL b/third_party/python/urllib3/urllib3-1.26.17.dist-info/WHEEL |
| 763 | similarity index 70% |
| 764 | rename from third_party/python/six/six-1.13.0.dist-info/WHEEL |
| 765 | rename to third_party/python/urllib3/urllib3-1.26.17.dist-info/WHEEL |
| 766 | index 8b701e93c2315..c34f1162ef9a5 100644 |
| 767 | --- a/third_party/python/six/six-1.13.0.dist-info/WHEEL |
| 768 | +++ b/third_party/python/urllib3/urllib3-1.26.17.dist-info/WHEEL |
| 769 | @@ -1,5 +1,5 @@ |
| 770 | Wheel-Version: 1.0 |
| 771 | -Generator: bdist_wheel (0.33.6) |
| 772 | +Generator: bdist_wheel (0.41.2) |
| 773 | Root-Is-Purelib: true |
| 774 | Tag: py2-none-any |
| 775 | Tag: py3-none-any |
| 776 | diff --git a/third_party/python/urllib3/urllib3-1.26.0.dist-info/top_level.txt b/third_party/python/urllib3/urllib3-1.26.17.dist-info/top_level.txt |
| 777 | similarity index 100% |
| 778 | rename from third_party/python/urllib3/urllib3-1.26.0.dist-info/top_level.txt |
| 779 | rename to third_party/python/urllib3/urllib3-1.26.17.dist-info/top_level.txt |
| 780 | diff --git a/third_party/python/urllib3/urllib3/__init__.py b/third_party/python/urllib3/urllib3/__init__.py |
| 781 | index fe86b59d782bd..c6fa38212fb55 100644 |
| 782 | --- a/third_party/python/urllib3/urllib3/__init__.py |
| 783 | +++ b/third_party/python/urllib3/urllib3/__init__.py |
| 784 | @@ -19,6 +19,23 @@ |
| 785 | from .util.timeout import Timeout |
| 786 | from .util.url import get_host |
| 787 | |
| 788 | +# === NOTE TO REPACKAGERS AND VENDORS === |
| 789 | +# Please delete this block, this logic is only |
| 790 | +# for urllib3 being distributed via PyPI. |
| 791 | +# See: https://github.com/urllib3/urllib3/issues/2680 |
| 792 | +try: |
| 793 | + import urllib3_secure_extra # type: ignore # noqa: F401 |
| 794 | +except ImportError: |
| 795 | + pass |
| 796 | +else: |
| 797 | + warnings.warn( |
| 798 | + "'urllib3[secure]' extra is deprecated and will be removed " |
| 799 | + "in a future release of urllib3 2.x. Read more in this issue: " |
| 800 | + "https://github.com/urllib3/urllib3/issues/2680", |
| 801 | + category=DeprecationWarning, |
| 802 | + stacklevel=2, |
| 803 | + ) |
| 804 | + |
| 805 | __author__ = "Andrey Petrov (andrey.petrov@shazow.net)" |
| 806 | __license__ = "MIT" |
| 807 | __version__ = __version__ |
| 808 | diff --git a/third_party/python/urllib3/urllib3/_version.py b/third_party/python/urllib3/urllib3/_version.py |
| 809 | index cee465f88a931..cad75fb5df82a 100644 |
| 810 | --- a/third_party/python/urllib3/urllib3/_version.py |
| 811 | +++ b/third_party/python/urllib3/urllib3/_version.py |
| 812 | @@ -1,2 +1,2 @@ |
| 813 | # This file is protected via CODEOWNERS |
| 814 | -__version__ = "1.26.0" |
| 815 | +__version__ = "1.26.17" |
| 816 | diff --git a/third_party/python/urllib3/urllib3/connection.py b/third_party/python/urllib3/urllib3/connection.py |
| 817 | index 52487417c946b..54b96b19154cc 100644 |
| 818 | --- a/third_party/python/urllib3/urllib3/connection.py |
| 819 | +++ b/third_party/python/urllib3/urllib3/connection.py |
| 820 | @@ -43,6 +43,7 @@ class BrokenPipeError(Exception): |
| 821 | pass |
| 822 | |
| 823 | |
| 824 | +from ._collections import HTTPHeaderDict # noqa (historical, removed in v2) |
| 825 | from ._version import __version__ |
| 826 | from .exceptions import ( |
| 827 | ConnectTimeoutError, |
| 828 | @@ -50,15 +51,16 @@ class BrokenPipeError(Exception): |
| 829 | SubjectAltNameWarning, |
| 830 | SystemTimeWarning, |
| 831 | ) |
| 832 | -from .packages.ssl_match_hostname import CertificateError, match_hostname |
| 833 | from .util import SKIP_HEADER, SKIPPABLE_HEADERS, connection |
| 834 | from .util.ssl_ import ( |
| 835 | assert_fingerprint, |
| 836 | create_urllib3_context, |
| 837 | + is_ipaddress, |
| 838 | resolve_cert_reqs, |
| 839 | resolve_ssl_version, |
| 840 | ssl_wrap_socket, |
| 841 | ) |
| 842 | +from .util.ssl_match_hostname import CertificateError, match_hostname |
| 843 | |
| 844 | log = logging.getLogger(__name__) |
| 845 | |
| 846 | @@ -66,7 +68,7 @@ class BrokenPipeError(Exception): |
| 847 | |
| 848 | # When it comes time to update this value as a part of regular maintenance |
| 849 | # (ie test_recent_date is failing) update it to ~6 months before the current date. |
| 850 | -RECENT_DATE = datetime.date(2019, 1, 1) |
| 851 | +RECENT_DATE = datetime.date(2022, 1, 1) |
| 852 | |
| 853 | _CONTAINS_CONTROL_CHAR_RE = re.compile(r"[^-!#$%&'*+.^_`|~0-9a-zA-Z]") |
| 854 | |
| 855 | @@ -106,6 +108,10 @@ class HTTPConnection(_HTTPConnection, object): |
| 856 | #: Whether this connection verifies the host's certificate. |
| 857 | is_verified = False |
| 858 | |
| 859 | + #: Whether this proxy connection (if used) verifies the proxy host's |
| 860 | + #: certificate. |
| 861 | + proxy_is_verified = None |
| 862 | + |
| 863 | def __init__(self, *args, **kw): |
| 864 | if not six.PY2: |
| 865 | kw.pop("strict", None) |
| 866 | @@ -200,7 +206,7 @@ def connect(self): |
| 867 | self._prepare_conn(conn) |
| 868 | |
| 869 | def putrequest(self, method, url, *args, **kwargs): |
| 870 | - """""" |
| 871 | + """ """ |
| 872 | # Empty docstring because the indentation of CPython's implementation |
| 873 | # is broken but we don't want this method in our documentation. |
| 874 | match = _CONTAINS_CONTROL_CHAR_RE.search(method) |
| 875 | @@ -213,8 +219,8 @@ def putrequest(self, method, url, *args, **kwargs): |
| 876 | return _HTTPConnection.putrequest(self, method, url, *args, **kwargs) |
| 877 | |
| 878 | def putheader(self, header, *values): |
| 879 | - """""" |
| 880 | - if SKIP_HEADER not in values: |
| 881 | + """ """ |
| 882 | + if not any(isinstance(v, str) and v == SKIP_HEADER for v in values): |
| 883 | _HTTPConnection.putheader(self, header, *values) |
| 884 | elif six.ensure_str(header.lower()) not in SKIPPABLE_HEADERS: |
| 885 | raise ValueError( |
| 886 | @@ -223,12 +229,17 @@ def putheader(self, header, *values): |
| 887 | ) |
| 888 | |
| 889 | def request(self, method, url, body=None, headers=None): |
| 890 | + # Update the inner socket's timeout value to send the request. |
| 891 | + # This only triggers if the connection is re-used. |
| 892 | + if getattr(self, "sock", None) is not None: |
| 893 | + self.sock.settimeout(self.timeout) |
| 894 | + |
| 895 | if headers is None: |
| 896 | headers = {} |
| 897 | else: |
| 898 | # Avoid modifying the headers passed into .request() |
| 899 | headers = headers.copy() |
| 900 | - if "user-agent" not in (k.lower() for k in headers): |
| 901 | + if "user-agent" not in (six.ensure_str(k.lower()) for k in headers): |
| 902 | headers["User-Agent"] = _get_default_user_agent() |
| 903 | super(HTTPConnection, self).request(method, url, body=body, headers=headers) |
| 904 | |
| 905 | @@ -248,7 +259,7 @@ def request_chunked(self, method, url, body=None, headers=None): |
| 906 | self.putheader("User-Agent", _get_default_user_agent()) |
| 907 | for header, value in headers.items(): |
| 908 | self.putheader(header, value) |
| 909 | - if "transfer-encoding" not in headers: |
| 910 | + if "transfer-encoding" not in header_keys: |
| 911 | self.putheader("Transfer-Encoding", "chunked") |
| 912 | self.endheaders() |
| 913 | |
| 914 | @@ -349,17 +360,15 @@ def set_cert( |
| 915 | |
| 916 | def connect(self): |
| 917 | # Add certificate verification |
| 918 | - conn = self._new_conn() |
| 919 | + self.sock = conn = self._new_conn() |
| 920 | hostname = self.host |
| 921 | tls_in_tls = False |
| 922 | |
| 923 | if self._is_using_tunnel(): |
| 924 | if self.tls_in_tls_required: |
| 925 | - conn = self._connect_tls_proxy(hostname, conn) |
| 926 | + self.sock = conn = self._connect_tls_proxy(hostname, conn) |
| 927 | tls_in_tls = True |
| 928 | |
| 929 | - self.sock = conn |
| 930 | - |
| 931 | # Calls self._set_hostport(), so self.host is |
| 932 | # self._tunnel_host below. |
| 933 | self._tunnel() |
| 934 | @@ -492,7 +501,7 @@ def _connect_tls_proxy(self, hostname, conn): |
| 935 | |
| 936 | # If no cert was provided, use only the default options for server |
| 937 | # certificate validation |
| 938 | - return ssl_wrap_socket( |
| 939 | + socket = ssl_wrap_socket( |
| 940 | sock=conn, |
| 941 | ca_certs=self.ca_certs, |
| 942 | ca_cert_dir=self.ca_cert_dir, |
| 943 | @@ -501,8 +510,37 @@ def _connect_tls_proxy(self, hostname, conn): |
| 944 | ssl_context=ssl_context, |
| 945 | ) |
| 946 | |
| 947 | + if ssl_context.verify_mode != ssl.CERT_NONE and not getattr( |
| 948 | + ssl_context, "check_hostname", False |
| 949 | + ): |
| 950 | + # While urllib3 attempts to always turn off hostname matching from |
| 951 | + # the TLS library, this cannot always be done. So we check whether |
| 952 | + # the TLS Library still thinks it's matching hostnames. |
| 953 | + cert = socket.getpeercert() |
| 954 | + if not cert.get("subjectAltName", ()): |
| 955 | + warnings.warn( |
| 956 | + ( |
| 957 | + "Certificate for {0} has no `subjectAltName`, falling back to check for a " |
| 958 | + "`commonName` for now. This feature is being removed by major browsers and " |
| 959 | + "deprecated by RFC 2818. (See https://github.com/urllib3/urllib3/issues/497 " |
| 960 | + "for details.)".format(hostname) |
| 961 | + ), |
| 962 | + SubjectAltNameWarning, |
| 963 | + ) |
| 964 | + _match_hostname(cert, hostname) |
| 965 | + |
| 966 | + self.proxy_is_verified = ssl_context.verify_mode == ssl.CERT_REQUIRED |
| 967 | + return socket |
| 968 | + |
| 969 | |
| 970 | def _match_hostname(cert, asserted_hostname): |
| 971 | + # Our upstream implementation of ssl.match_hostname() |
| 972 | + # only applies this normalization to IP addresses so it doesn't |
| 973 | + # match DNS SANs so we do the same thing! |
| 974 | + stripped_hostname = asserted_hostname.strip("u[]") |
| 975 | + if is_ipaddress(stripped_hostname): |
| 976 | + asserted_hostname = stripped_hostname |
| 977 | + |
| 978 | try: |
| 979 | match_hostname(cert, asserted_hostname) |
| 980 | except CertificateError as e: |
| 981 | diff --git a/third_party/python/urllib3/urllib3/connectionpool.py b/third_party/python/urllib3/urllib3/connectionpool.py |
| 982 | index 4708c5bfc7862..96844d933745d 100644 |
| 983 | --- a/third_party/python/urllib3/urllib3/connectionpool.py |
| 984 | +++ b/third_party/python/urllib3/urllib3/connectionpool.py |
| 985 | @@ -2,6 +2,7 @@ |
| 986 | |
| 987 | import errno |
| 988 | import logging |
| 989 | +import re |
| 990 | import socket |
| 991 | import sys |
| 992 | import warnings |
| 993 | @@ -35,7 +36,6 @@ |
| 994 | ) |
| 995 | from .packages import six |
| 996 | from .packages.six.moves import queue |
| 997 | -from .packages.ssl_match_hostname import CertificateError |
| 998 | from .request import RequestMethods |
| 999 | from .response import HTTPResponse |
| 1000 | from .util.connection import is_connection_dropped |
| 1001 | @@ -44,11 +44,19 @@ |
| 1002 | from .util.request import set_file_position |
| 1003 | from .util.response import assert_header_parsing |
| 1004 | from .util.retry import Retry |
| 1005 | +from .util.ssl_match_hostname import CertificateError |
| 1006 | from .util.timeout import Timeout |
| 1007 | from .util.url import Url, _encode_target |
| 1008 | from .util.url import _normalize_host as normalize_host |
| 1009 | from .util.url import get_host, parse_url |
| 1010 | |
| 1011 | +try: # Platform-specific: Python 3 |
| 1012 | + import weakref |
| 1013 | + |
| 1014 | + weakref_finalize = weakref.finalize |
| 1015 | +except AttributeError: # Platform-specific: Python 2 |
| 1016 | + from .packages.backports.weakref_finalize import weakref_finalize |
| 1017 | + |
| 1018 | xrange = six.moves.xrange |
| 1019 | |
| 1020 | log = logging.getLogger(__name__) |
| 1021 | @@ -219,6 +227,16 @@ def __init__( |
| 1022 | self.conn_kw["proxy"] = self.proxy |
| 1023 | self.conn_kw["proxy_config"] = self.proxy_config |
| 1024 | |
| 1025 | + # Do not pass 'self' as callback to 'finalize'. |
| 1026 | + # Then the 'finalize' would keep an endless living (leak) to self. |
| 1027 | + # By just passing a reference to the pool allows the garbage collector |
| 1028 | + # to free self if nobody else has a reference to it. |
| 1029 | + pool = self.pool |
| 1030 | + |
| 1031 | + # Close all the HTTPConnections in the pool before the |
| 1032 | + # HTTPConnectionPool object is garbage collected. |
| 1033 | + weakref_finalize(self, _close_pool_connections, pool) |
| 1034 | + |
| 1035 | def _new_conn(self): |
| 1036 | """ |
| 1037 | Return a fresh :class:`HTTPConnection`. |
| 1038 | @@ -301,8 +319,11 @@ def _put_conn(self, conn): |
| 1039 | pass |
| 1040 | except queue.Full: |
| 1041 | # This should never happen if self.block == True |
| 1042 | - log.warning("Connection pool is full, discarding connection: %s", self.host) |
| 1043 | - |
| 1044 | + log.warning( |
| 1045 | + "Connection pool is full, discarding connection: %s. Connection pool size: %s", |
| 1046 | + self.host, |
| 1047 | + self.pool.qsize(), |
| 1048 | + ) |
| 1049 | # Connection never got put back into the pool, close it. |
| 1050 | if conn: |
| 1051 | conn.close() |
| 1052 | @@ -318,7 +339,7 @@ def _prepare_proxy(self, conn): |
| 1053 | pass |
| 1054 | |
| 1055 | def _get_timeout(self, timeout): |
| 1056 | - """ Helper that always returns a :class:`urllib3.util.Timeout` """ |
| 1057 | + """Helper that always returns a :class:`urllib3.util.Timeout`""" |
| 1058 | if timeout is _Default: |
| 1059 | return self.timeout.clone() |
| 1060 | |
| 1061 | @@ -375,7 +396,7 @@ def _make_request( |
| 1062 | |
| 1063 | timeout_obj = self._get_timeout(timeout) |
| 1064 | timeout_obj.start_connect() |
| 1065 | - conn.timeout = timeout_obj.connect_timeout |
| 1066 | + conn.timeout = Timeout.resolve_default_timeout(timeout_obj.connect_timeout) |
| 1067 | |
| 1068 | # Trigger any extra validation we need to do. |
| 1069 | try: |
| 1070 | @@ -485,14 +506,8 @@ def close(self): |
| 1071 | # Disable access to the pool |
| 1072 | old_pool, self.pool = self.pool, None |
| 1073 | |
| 1074 | - try: |
| 1075 | - while True: |
| 1076 | - conn = old_pool.get(block=False) |
| 1077 | - if conn: |
| 1078 | - conn.close() |
| 1079 | - |
| 1080 | - except queue.Empty: |
| 1081 | - pass # Done. |
| 1082 | + # Close all the HTTPConnections in the pool. |
| 1083 | + _close_pool_connections(old_pool) |
| 1084 | |
| 1085 | def is_same_host(self, url): |
| 1086 | """ |
| 1087 | @@ -745,7 +760,35 @@ def urlopen( |
| 1088 | # Discard the connection for these exceptions. It will be |
| 1089 | # replaced during the next _get_conn() call. |
| 1090 | clean_exit = False |
| 1091 | - if isinstance(e, (BaseSSLError, CertificateError)): |
| 1092 | + |
| 1093 | + def _is_ssl_error_message_from_http_proxy(ssl_error): |
| 1094 | + # We're trying to detect the message 'WRONG_VERSION_NUMBER' but |
| 1095 | + # SSLErrors are kinda all over the place when it comes to the message, |
| 1096 | + # so we try to cover our bases here! |
| 1097 | + message = " ".join(re.split("[^a-z]", str(ssl_error).lower())) |
| 1098 | + return ( |
| 1099 | + "wrong version number" in message or "unknown protocol" in message |
| 1100 | + ) |
| 1101 | + |
| 1102 | + # Try to detect a common user error with proxies which is to |
| 1103 | + # set an HTTP proxy to be HTTPS when it should be 'http://' |
| 1104 | + # (ie {'http': 'http://proxy', 'https': 'https://proxy'}) |
| 1105 | + # Instead we add a nice error message and point to a URL. |
| 1106 | + if ( |
| 1107 | + isinstance(e, BaseSSLError) |
| 1108 | + and self.proxy |
| 1109 | + and _is_ssl_error_message_from_http_proxy(e) |
| 1110 | + and conn.proxy |
| 1111 | + and conn.proxy.scheme == "https" |
| 1112 | + ): |
| 1113 | + e = ProxyError( |
| 1114 | + "Your proxy appears to only use HTTP and not HTTPS, " |
| 1115 | + "try changing your proxy URL to be HTTP. See: " |
| 1116 | + "https://urllib3.readthedocs.io/en/1.26.x/advanced-usage.html" |
| 1117 | + "#https-proxy-error-http-proxy", |
| 1118 | + SSLError(e), |
| 1119 | + ) |
| 1120 | + elif isinstance(e, (BaseSSLError, CertificateError)): |
| 1121 | e = SSLError(e) |
| 1122 | elif isinstance(e, (SocketError, NewConnectionError)) and self.proxy: |
| 1123 | e = ProxyError("Cannot connect to proxy.", e) |
| 1124 | @@ -830,7 +873,7 @@ def urlopen( |
| 1125 | ) |
| 1126 | |
| 1127 | # Check if we should retry the HTTP response. |
| 1128 | - has_retry_after = bool(response.getheader("Retry-After")) |
| 1129 | + has_retry_after = bool(response.headers.get("Retry-After")) |
| 1130 | if retries.is_retry(method, response.status, has_retry_after): |
| 1131 | try: |
| 1132 | retries = retries.increment(method, url, response=response, _pool=self) |
| 1133 | @@ -1014,12 +1057,23 @@ def _validate_conn(self, conn): |
| 1134 | ( |
| 1135 | "Unverified HTTPS request is being made to host '%s'. " |
| 1136 | "Adding certificate verification is strongly advised. See: " |
| 1137 | - "https://urllib3.readthedocs.io/en/latest/advanced-usage.html" |
| 1138 | + "https://urllib3.readthedocs.io/en/1.26.x/advanced-usage.html" |
| 1139 | "#ssl-warnings" % conn.host |
| 1140 | ), |
| 1141 | InsecureRequestWarning, |
| 1142 | ) |
| 1143 | |
| 1144 | + if getattr(conn, "proxy_is_verified", None) is False: |
| 1145 | + warnings.warn( |
| 1146 | + ( |
| 1147 | + "Unverified HTTPS connection done to an HTTPS proxy. " |
| 1148 | + "Adding certificate verification is strongly advised. See: " |
| 1149 | + "https://urllib3.readthedocs.io/en/1.26.x/advanced-usage.html" |
| 1150 | + "#ssl-warnings" |
| 1151 | + ), |
| 1152 | + InsecureRequestWarning, |
| 1153 | + ) |
| 1154 | + |
| 1155 | |
| 1156 | def connection_from_url(url, **kw): |
| 1157 | """ |
| 1158 | @@ -1065,3 +1119,14 @@ def _normalize_host(host, scheme): |
| 1159 | if host.startswith("[") and host.endswith("]"): |
| 1160 | host = host[1:-1] |
| 1161 | return host |
| 1162 | + |
| 1163 | + |
| 1164 | +def _close_pool_connections(pool): |
| 1165 | + """Drains a queue of connections and closes each one.""" |
| 1166 | + try: |
| 1167 | + while True: |
| 1168 | + conn = pool.get(block=False) |
| 1169 | + if conn: |
| 1170 | + conn.close() |
| 1171 | + except queue.Empty: |
| 1172 | + pass # Done. |
| 1173 | diff --git a/third_party/python/urllib3/urllib3/contrib/_securetransport/bindings.py b/third_party/python/urllib3/urllib3/contrib/_securetransport/bindings.py |
| 1174 | index 11524d400bab2..264d564dbda67 100644 |
| 1175 | --- a/third_party/python/urllib3/urllib3/contrib/_securetransport/bindings.py |
| 1176 | +++ b/third_party/python/urllib3/urllib3/contrib/_securetransport/bindings.py |
| 1177 | @@ -48,7 +48,7 @@ |
| 1178 | ) |
| 1179 | from ctypes.util import find_library |
| 1180 | |
| 1181 | -from urllib3.packages.six import raise_from |
| 1182 | +from ...packages.six import raise_from |
| 1183 | |
| 1184 | if platform.system() != "Darwin": |
| 1185 | raise ImportError("Only macOS is supported") |
| 1186 | diff --git a/third_party/python/urllib3/urllib3/contrib/_securetransport/low_level.py b/third_party/python/urllib3/urllib3/contrib/_securetransport/low_level.py |
| 1187 | index ed8120190c06f..fa0b245d279e9 100644 |
| 1188 | --- a/third_party/python/urllib3/urllib3/contrib/_securetransport/low_level.py |
| 1189 | +++ b/third_party/python/urllib3/urllib3/contrib/_securetransport/low_level.py |
| 1190 | @@ -188,6 +188,7 @@ def _cert_array_from_pem(pem_bundle): |
| 1191 | # We only want to do that if an error occurs: otherwise, the caller |
| 1192 | # should free. |
| 1193 | CoreFoundation.CFRelease(cert_array) |
| 1194 | + raise |
| 1195 | |
| 1196 | return cert_array |
| 1197 | |
| 1198 | diff --git a/third_party/python/urllib3/urllib3/contrib/appengine.py b/third_party/python/urllib3/urllib3/contrib/appengine.py |
| 1199 | index aa64a0914c601..a5a6d91035f0a 100644 |
| 1200 | --- a/third_party/python/urllib3/urllib3/contrib/appengine.py |
| 1201 | +++ b/third_party/python/urllib3/urllib3/contrib/appengine.py |
| 1202 | @@ -111,7 +111,7 @@ def __init__( |
| 1203 | warnings.warn( |
| 1204 | "urllib3 is using URLFetch on Google App Engine sandbox instead " |
| 1205 | "of sockets. To use sockets directly instead of URLFetch see " |
| 1206 | - "https://urllib3.readthedocs.io/en/latest/reference/urllib3.contrib.html.", |
| 1207 | + "https://urllib3.readthedocs.io/en/1.26.x/reference/urllib3.contrib.html.", |
| 1208 | AppEnginePlatformWarning, |
| 1209 | ) |
| 1210 | |
| 1211 | @@ -224,7 +224,7 @@ def urlopen( |
| 1212 | ) |
| 1213 | |
| 1214 | # Check if we should retry the HTTP response. |
| 1215 | - has_retry_after = bool(http_response.getheader("Retry-After")) |
| 1216 | + has_retry_after = bool(http_response.headers.get("Retry-After")) |
| 1217 | if retries.is_retry(method, http_response.status, has_retry_after): |
| 1218 | retries = retries.increment(method, url, response=http_response, _pool=self) |
| 1219 | log.debug("Retry: %s", url) |
| 1220 | diff --git a/third_party/python/urllib3/urllib3/contrib/ntlmpool.py b/third_party/python/urllib3/urllib3/contrib/ntlmpool.py |
| 1221 | index b2df45dcf6065..471665754e9f1 100644 |
| 1222 | --- a/third_party/python/urllib3/urllib3/contrib/ntlmpool.py |
| 1223 | +++ b/third_party/python/urllib3/urllib3/contrib/ntlmpool.py |
| 1224 | @@ -5,6 +5,7 @@ |
| 1225 | """ |
| 1226 | from __future__ import absolute_import |
| 1227 | |
| 1228 | +import warnings |
| 1229 | from logging import getLogger |
| 1230 | |
| 1231 | from ntlm import ntlm |
| 1232 | @@ -12,6 +13,14 @@ |
| 1233 | from .. import HTTPSConnectionPool |
| 1234 | from ..packages.six.moves.http_client import HTTPSConnection |
| 1235 | |
| 1236 | +warnings.warn( |
| 1237 | + "The 'urllib3.contrib.ntlmpool' module is deprecated and will be removed " |
| 1238 | + "in urllib3 v2.0 release, urllib3 is not able to support it properly due " |
| 1239 | + "to reasons listed in issue: https://github.com/urllib3/urllib3/issues/2282. " |
| 1240 | + "If you are a user of this module please comment in the mentioned issue.", |
| 1241 | + DeprecationWarning, |
| 1242 | +) |
| 1243 | + |
| 1244 | log = getLogger(__name__) |
| 1245 | |
| 1246 | |
| 1247 | @@ -60,7 +69,7 @@ def _new_conn(self): |
| 1248 | log.debug("Request headers: %s", headers) |
| 1249 | conn.request("GET", self.authurl, None, headers) |
| 1250 | res = conn.getresponse() |
| 1251 | - reshdr = dict(res.getheaders()) |
| 1252 | + reshdr = dict(res.headers) |
| 1253 | log.debug("Response status: %s %s", res.status, res.reason) |
| 1254 | log.debug("Response headers: %s", reshdr) |
| 1255 | log.debug("Response data: %s [...]", res.read(100)) |
| 1256 | @@ -92,7 +101,7 @@ def _new_conn(self): |
| 1257 | conn.request("GET", self.authurl, None, headers) |
| 1258 | res = conn.getresponse() |
| 1259 | log.debug("Response status: %s %s", res.status, res.reason) |
| 1260 | - log.debug("Response headers: %s", dict(res.getheaders())) |
| 1261 | + log.debug("Response headers: %s", dict(res.headers)) |
| 1262 | log.debug("Response data: %s [...]", res.read()[:100]) |
| 1263 | if res.status != 200: |
| 1264 | if res.status == 401: |
| 1265 | diff --git a/third_party/python/urllib3/urllib3/contrib/pyopenssl.py b/third_party/python/urllib3/urllib3/contrib/pyopenssl.py |
| 1266 | index 0cabab1aed14a..1ed214b1d78fc 100644 |
| 1267 | --- a/third_party/python/urllib3/urllib3/contrib/pyopenssl.py |
| 1268 | +++ b/third_party/python/urllib3/urllib3/contrib/pyopenssl.py |
| 1269 | @@ -47,10 +47,10 @@ |
| 1270 | """ |
| 1271 | from __future__ import absolute_import |
| 1272 | |
| 1273 | +import OpenSSL.crypto |
| 1274 | import OpenSSL.SSL |
| 1275 | from cryptography import x509 |
| 1276 | from cryptography.hazmat.backends.openssl import backend as openssl_backend |
| 1277 | -from cryptography.hazmat.backends.openssl.x509 import _Certificate |
| 1278 | |
| 1279 | try: |
| 1280 | from cryptography.x509 import UnsupportedExtension |
| 1281 | @@ -73,9 +73,19 @@ class UnsupportedExtension(Exception): |
| 1282 | import logging |
| 1283 | import ssl |
| 1284 | import sys |
| 1285 | +import warnings |
| 1286 | |
| 1287 | from .. import util |
| 1288 | from ..packages import six |
| 1289 | +from ..util.ssl_ import PROTOCOL_TLS_CLIENT |
| 1290 | + |
| 1291 | +warnings.warn( |
| 1292 | + "'urllib3.contrib.pyopenssl' module is deprecated and will be removed " |
| 1293 | + "in a future release of urllib3 2.x. Read more in this issue: " |
| 1294 | + "https://github.com/urllib3/urllib3/issues/2680", |
| 1295 | + category=DeprecationWarning, |
| 1296 | + stacklevel=2, |
| 1297 | +) |
| 1298 | |
| 1299 | __all__ = ["inject_into_urllib3", "extract_from_urllib3"] |
| 1300 | |
| 1301 | @@ -85,6 +95,7 @@ class UnsupportedExtension(Exception): |
| 1302 | # Map from urllib3 to PyOpenSSL compatible parameter-values. |
| 1303 | _openssl_versions = { |
| 1304 | util.PROTOCOL_TLS: OpenSSL.SSL.SSLv23_METHOD, |
| 1305 | + PROTOCOL_TLS_CLIENT: OpenSSL.SSL.SSLv23_METHOD, |
| 1306 | ssl.PROTOCOL_TLSv1: OpenSSL.SSL.TLSv1_METHOD, |
| 1307 | } |
| 1308 | |
| 1309 | @@ -217,9 +228,8 @@ def get_subj_alt_name(peer_cert): |
| 1310 | if hasattr(peer_cert, "to_cryptography"): |
| 1311 | cert = peer_cert.to_cryptography() |
| 1312 | else: |
| 1313 | - # This is technically using private APIs, but should work across all |
| 1314 | - # relevant versions before PyOpenSSL got a proper API for this. |
| 1315 | - cert = _Certificate(openssl_backend, peer_cert._x509) |
| 1316 | + der = OpenSSL.crypto.dump_certificate(OpenSSL.crypto.FILETYPE_ASN1, peer_cert) |
| 1317 | + cert = x509.load_der_x509_certificate(der, openssl_backend) |
| 1318 | |
| 1319 | # We want to find the SAN extension. Ask Cryptography to locate it (it's |
| 1320 | # faster than looping in Python) |
| 1321 | @@ -404,7 +414,6 @@ def makefile(self, mode, bufsize=-1): |
| 1322 | self._makefile_refs += 1 |
| 1323 | return _fileobject(self, mode, bufsize, close=True) |
| 1324 | |
| 1325 | - |
| 1326 | else: # Platform-specific: Python 3 |
| 1327 | makefile = backport_makefile |
| 1328 | |
| 1329 | diff --git a/third_party/python/urllib3/urllib3/contrib/securetransport.py b/third_party/python/urllib3/urllib3/contrib/securetransport.py |
| 1330 | index ab092de67a57c..6c46a3b9f0375 100644 |
| 1331 | --- a/third_party/python/urllib3/urllib3/contrib/securetransport.py |
| 1332 | +++ b/third_party/python/urllib3/urllib3/contrib/securetransport.py |
| 1333 | @@ -67,6 +67,7 @@ |
| 1334 | import six |
| 1335 | |
| 1336 | from .. import util |
| 1337 | +from ..util.ssl_ import PROTOCOL_TLS_CLIENT |
| 1338 | from ._securetransport.bindings import CoreFoundation, Security, SecurityConst |
| 1339 | from ._securetransport.low_level import ( |
| 1340 | _assert_no_error, |
| 1341 | @@ -154,7 +155,8 @@ |
| 1342 | # TLSv1 and a high of TLSv1.2. For everything else, we pin to that version. |
| 1343 | # TLSv1 to 1.2 are supported on macOS 10.8+ |
| 1344 | _protocol_to_min_max = { |
| 1345 | - util.PROTOCOL_TLS: (SecurityConst.kTLSProtocol1, SecurityConst.kTLSProtocol12) |
| 1346 | + util.PROTOCOL_TLS: (SecurityConst.kTLSProtocol1, SecurityConst.kTLSProtocol12), |
| 1347 | + PROTOCOL_TLS_CLIENT: (SecurityConst.kTLSProtocol1, SecurityConst.kTLSProtocol12), |
| 1348 | } |
| 1349 | |
| 1350 | if hasattr(ssl, "PROTOCOL_SSLv2"): |
| 1351 | @@ -768,7 +770,6 @@ def makefile(self, mode, bufsize=-1): |
| 1352 | self._makefile_refs += 1 |
| 1353 | return _fileobject(self, mode, bufsize, close=True) |
| 1354 | |
| 1355 | - |
| 1356 | else: # Platform-specific: Python 3 |
| 1357 | |
| 1358 | def makefile(self, mode="r", buffering=None, *args, **kwargs): |
| 1359 | diff --git a/third_party/python/urllib3/urllib3/contrib/socks.py b/third_party/python/urllib3/urllib3/contrib/socks.py |
| 1360 | index 93df8325d59c4..c326e80dd1174 100644 |
| 1361 | --- a/third_party/python/urllib3/urllib3/contrib/socks.py |
| 1362 | +++ b/third_party/python/urllib3/urllib3/contrib/socks.py |
| 1363 | @@ -51,7 +51,7 @@ |
| 1364 | ( |
| 1365 | "SOCKS support in urllib3 requires the installation of optional " |
| 1366 | "dependencies: specifically, PySocks. For more information, see " |
| 1367 | - "https://urllib3.readthedocs.io/en/latest/contrib.html#socks-proxies" |
| 1368 | + "https://urllib3.readthedocs.io/en/1.26.x/contrib.html#socks-proxies" |
| 1369 | ), |
| 1370 | DependencyWarning, |
| 1371 | ) |
| 1372 | diff --git a/third_party/python/urllib3/urllib3/exceptions.py b/third_party/python/urllib3/urllib3/exceptions.py |
| 1373 | index d69958d5dfc29..cba6f3f560f71 100644 |
| 1374 | --- a/third_party/python/urllib3/urllib3/exceptions.py |
| 1375 | +++ b/third_party/python/urllib3/urllib3/exceptions.py |
| 1376 | @@ -289,7 +289,17 @@ class ProxySchemeUnknown(AssertionError, URLSchemeUnknown): |
| 1377 | # TODO(t-8ch): Stop inheriting from AssertionError in v2.0. |
| 1378 | |
| 1379 | def __init__(self, scheme): |
| 1380 | - message = "Not supported proxy scheme %s" % scheme |
| 1381 | + # 'localhost' is here because our URL parser parses |
| 1382 | + # localhost:8080 -> scheme=localhost, remove if we fix this. |
| 1383 | + if scheme == "localhost": |
| 1384 | + scheme = None |
| 1385 | + if scheme is None: |
| 1386 | + message = "Proxy URL had no scheme, should start with http:// or https://" |
| 1387 | + else: |
| 1388 | + message = ( |
| 1389 | + "Proxy URL had unsupported scheme %s, should use http:// or https://" |
| 1390 | + % scheme |
| 1391 | + ) |
| 1392 | super(ProxySchemeUnknown, self).__init__(message) |
| 1393 | |
| 1394 | |
| 1395 | diff --git a/third_party/python/urllib3/urllib3/packages/__init__.py b/third_party/python/urllib3/urllib3/packages/__init__.py |
| 1396 | index fce4caa65d2ee..e69de29bb2d1d 100644 |
| 1397 | --- a/third_party/python/urllib3/urllib3/packages/__init__.py |
| 1398 | +++ b/third_party/python/urllib3/urllib3/packages/__init__.py |
| 1399 | @@ -1,5 +0,0 @@ |
| 1400 | -from __future__ import absolute_import |
| 1401 | - |
| 1402 | -from . import ssl_match_hostname |
| 1403 | - |
| 1404 | -__all__ = ("ssl_match_hostname",) |
| 1405 | diff --git a/third_party/python/urllib3/urllib3/packages/backports/weakref_finalize.py b/third_party/python/urllib3/urllib3/packages/backports/weakref_finalize.py |
| 1406 | new file mode 100644 |
| 1407 | index 0000000000000..a2f2966e54966 |
| 1408 | --- /dev/null |
| 1409 | +++ b/third_party/python/urllib3/urllib3/packages/backports/weakref_finalize.py |
| 1410 | @@ -0,0 +1,155 @@ |
| 1411 | +# -*- coding: utf-8 -*- |
| 1412 | +""" |
| 1413 | +backports.weakref_finalize |
| 1414 | +~~~~~~~~~~~~~~~~~~ |
| 1415 | + |
| 1416 | +Backports the Python 3 ``weakref.finalize`` method. |
| 1417 | +""" |
| 1418 | +from __future__ import absolute_import |
| 1419 | + |
| 1420 | +import itertools |
| 1421 | +import sys |
| 1422 | +from weakref import ref |
| 1423 | + |
| 1424 | +__all__ = ["weakref_finalize"] |
| 1425 | + |
| 1426 | + |
| 1427 | +class weakref_finalize(object): |
| 1428 | + """Class for finalization of weakrefable objects |
| 1429 | + finalize(obj, func, *args, **kwargs) returns a callable finalizer |
| 1430 | + object which will be called when obj is garbage collected. The |
| 1431 | + first time the finalizer is called it evaluates func(*arg, **kwargs) |
| 1432 | + and returns the result. After this the finalizer is dead, and |
| 1433 | + calling it just returns None. |
| 1434 | + When the program exits any remaining finalizers for which the |
| 1435 | + atexit attribute is true will be run in reverse order of creation. |
| 1436 | + By default atexit is true. |
| 1437 | + """ |
| 1438 | + |
| 1439 | + # Finalizer objects don't have any state of their own. They are |
| 1440 | + # just used as keys to lookup _Info objects in the registry. This |
| 1441 | + # ensures that they cannot be part of a ref-cycle. |
| 1442 | + |
| 1443 | + __slots__ = () |
| 1444 | + _registry = {} |
| 1445 | + _shutdown = False |
| 1446 | + _index_iter = itertools.count() |
| 1447 | + _dirty = False |
| 1448 | + _registered_with_atexit = False |
| 1449 | + |
| 1450 | + class _Info(object): |
| 1451 | + __slots__ = ("weakref", "func", "args", "kwargs", "atexit", "index") |
| 1452 | + |
| 1453 | + def __init__(self, obj, func, *args, **kwargs): |
| 1454 | + if not self._registered_with_atexit: |
| 1455 | + # We may register the exit function more than once because |
| 1456 | + # of a thread race, but that is harmless |
| 1457 | + import atexit |
| 1458 | + |
| 1459 | + atexit.register(self._exitfunc) |
| 1460 | + weakref_finalize._registered_with_atexit = True |
| 1461 | + info = self._Info() |
| 1462 | + info.weakref = ref(obj, self) |
| 1463 | + info.func = func |
| 1464 | + info.args = args |
| 1465 | + info.kwargs = kwargs or None |
| 1466 | + info.atexit = True |
| 1467 | + info.index = next(self._index_iter) |
| 1468 | + self._registry[self] = info |
| 1469 | + weakref_finalize._dirty = True |
| 1470 | + |
| 1471 | + def __call__(self, _=None): |
| 1472 | + """If alive then mark as dead and return func(*args, **kwargs); |
| 1473 | + otherwise return None""" |
| 1474 | + info = self._registry.pop(self, None) |
| 1475 | + if info and not self._shutdown: |
| 1476 | + return info.func(*info.args, **(info.kwargs or {})) |
| 1477 | + |
| 1478 | + def detach(self): |
| 1479 | + """If alive then mark as dead and return (obj, func, args, kwargs); |
| 1480 | + otherwise return None""" |
| 1481 | + info = self._registry.get(self) |
| 1482 | + obj = info and info.weakref() |
| 1483 | + if obj is not None and self._registry.pop(self, None): |
| 1484 | + return (obj, info.func, info.args, info.kwargs or {}) |
| 1485 | + |
| 1486 | + def peek(self): |
| 1487 | + """If alive then return (obj, func, args, kwargs); |
| 1488 | + otherwise return None""" |
| 1489 | + info = self._registry.get(self) |
| 1490 | + obj = info and info.weakref() |
| 1491 | + if obj is not None: |
| 1492 | + return (obj, info.func, info.args, info.kwargs or {}) |
| 1493 | + |
| 1494 | + @property |
| 1495 | + def alive(self): |
| 1496 | + """Whether finalizer is alive""" |
| 1497 | + return self in self._registry |
| 1498 | + |
| 1499 | + @property |
| 1500 | + def atexit(self): |
| 1501 | + """Whether finalizer should be called at exit""" |
| 1502 | + info = self._registry.get(self) |
| 1503 | + return bool(info) and info.atexit |
| 1504 | + |
| 1505 | + @atexit.setter |
| 1506 | + def atexit(self, value): |
| 1507 | + info = self._registry.get(self) |
| 1508 | + if info: |
| 1509 | + info.atexit = bool(value) |
| 1510 | + |
| 1511 | + def __repr__(self): |
| 1512 | + info = self._registry.get(self) |
| 1513 | + obj = info and info.weakref() |
| 1514 | + if obj is None: |
| 1515 | + return "<%s object at %#x; dead>" % (type(self).__name__, id(self)) |
| 1516 | + else: |
| 1517 | + return "<%s object at %#x; for %r at %#x>" % ( |
| 1518 | + type(self).__name__, |
| 1519 | + id(self), |
| 1520 | + type(obj).__name__, |
| 1521 | + id(obj), |
| 1522 | + ) |
| 1523 | + |
| 1524 | + @classmethod |
| 1525 | + def _select_for_exit(cls): |
| 1526 | + # Return live finalizers marked for exit, oldest first |
| 1527 | + L = [(f, i) for (f, i) in cls._registry.items() if i.atexit] |
| 1528 | + L.sort(key=lambda item: item[1].index) |
| 1529 | + return [f for (f, i) in L] |
| 1530 | + |
| 1531 | + @classmethod |
| 1532 | + def _exitfunc(cls): |
| 1533 | + # At shutdown invoke finalizers for which atexit is true. |
| 1534 | + # This is called once all other non-daemonic threads have been |
| 1535 | + # joined. |
| 1536 | + reenable_gc = False |
| 1537 | + try: |
| 1538 | + if cls._registry: |
| 1539 | + import gc |
| 1540 | + |
| 1541 | + if gc.isenabled(): |
| 1542 | + reenable_gc = True |
| 1543 | + gc.disable() |
| 1544 | + pending = None |
| 1545 | + while True: |
| 1546 | + if pending is None or weakref_finalize._dirty: |
| 1547 | + pending = cls._select_for_exit() |
| 1548 | + weakref_finalize._dirty = False |
| 1549 | + if not pending: |
| 1550 | + break |
| 1551 | + f = pending.pop() |
| 1552 | + try: |
| 1553 | + # gc is disabled, so (assuming no daemonic |
| 1554 | + # threads) the following is the only line in |
| 1555 | + # this function which might trigger creation |
| 1556 | + # of a new finalizer |
| 1557 | + f() |
| 1558 | + except Exception: |
| 1559 | + sys.excepthook(*sys.exc_info()) |
| 1560 | + assert f not in cls._registry |
| 1561 | + finally: |
| 1562 | + # prevent any more finalizers from executing during shutdown |
| 1563 | + weakref_finalize._shutdown = True |
| 1564 | + if reenable_gc: |
| 1565 | + gc.enable() |
| 1566 | diff --git a/third_party/python/urllib3/urllib3/packages/six.py b/third_party/python/urllib3/urllib3/packages/six.py |
| 1567 | index 314424099f624..f099a3dcd28d2 100644 |
| 1568 | --- a/third_party/python/urllib3/urllib3/packages/six.py |
| 1569 | +++ b/third_party/python/urllib3/urllib3/packages/six.py |
| 1570 | @@ -1,4 +1,4 @@ |
| 1571 | -# Copyright (c) 2010-2019 Benjamin Peterson |
| 1572 | +# Copyright (c) 2010-2020 Benjamin Peterson |
| 1573 | # |
| 1574 | # Permission is hereby granted, free of charge, to any person obtaining a copy |
| 1575 | # of this software and associated documentation files (the "Software"), to deal |
| 1576 | @@ -29,7 +29,7 @@ |
| 1577 | import types |
| 1578 | |
| 1579 | __author__ = "Benjamin Peterson <benjamin@python.org>" |
| 1580 | -__version__ = "1.12.0" |
| 1581 | +__version__ = "1.16.0" |
| 1582 | |
| 1583 | |
| 1584 | # Useful for very coarse version differentiation. |
| 1585 | @@ -71,6 +71,11 @@ def __len__(self): |
| 1586 | MAXSIZE = int((1 << 63) - 1) |
| 1587 | del X |
| 1588 | |
| 1589 | +if PY34: |
| 1590 | + from importlib.util import spec_from_loader |
| 1591 | +else: |
| 1592 | + spec_from_loader = None |
| 1593 | + |
| 1594 | |
| 1595 | def _add_doc(func, doc): |
| 1596 | """Add documentation to a function.""" |
| 1597 | @@ -182,6 +187,11 @@ def find_module(self, fullname, path=None): |
| 1598 | return self |
| 1599 | return None |
| 1600 | |
| 1601 | + def find_spec(self, fullname, path, target=None): |
| 1602 | + if fullname in self.known_modules: |
| 1603 | + return spec_from_loader(fullname, self) |
| 1604 | + return None |
| 1605 | + |
| 1606 | def __get_module(self, fullname): |
| 1607 | try: |
| 1608 | return self.known_modules[fullname] |
| 1609 | @@ -220,6 +230,12 @@ def get_code(self, fullname): |
| 1610 | |
| 1611 | get_source = get_code # same as get_code |
| 1612 | |
| 1613 | + def create_module(self, spec): |
| 1614 | + return self.load_module(spec.name) |
| 1615 | + |
| 1616 | + def exec_module(self, module): |
| 1617 | + pass |
| 1618 | + |
| 1619 | |
| 1620 | _importer = _SixMetaPathImporter(__name__) |
| 1621 | |
| 1622 | @@ -260,9 +276,19 @@ class _MovedItems(_LazyModule): |
| 1623 | ), |
| 1624 | MovedModule("builtins", "__builtin__"), |
| 1625 | MovedModule("configparser", "ConfigParser"), |
| 1626 | + MovedModule( |
| 1627 | + "collections_abc", |
| 1628 | + "collections", |
| 1629 | + "collections.abc" if sys.version_info >= (3, 3) else "collections", |
| 1630 | + ), |
| 1631 | MovedModule("copyreg", "copy_reg"), |
| 1632 | MovedModule("dbm_gnu", "gdbm", "dbm.gnu"), |
| 1633 | - MovedModule("_dummy_thread", "dummy_thread", "_dummy_thread"), |
| 1634 | + MovedModule("dbm_ndbm", "dbm", "dbm.ndbm"), |
| 1635 | + MovedModule( |
| 1636 | + "_dummy_thread", |
| 1637 | + "dummy_thread", |
| 1638 | + "_dummy_thread" if sys.version_info < (3, 9) else "_thread", |
| 1639 | + ), |
| 1640 | MovedModule("http_cookiejar", "cookielib", "http.cookiejar"), |
| 1641 | MovedModule("http_cookies", "Cookie", "http.cookies"), |
| 1642 | MovedModule("html_entities", "htmlentitydefs", "html.entities"), |
| 1643 | @@ -307,7 +333,9 @@ class _MovedItems(_LazyModule): |
| 1644 | ] |
| 1645 | # Add windows specific modules. |
| 1646 | if sys.platform == "win32": |
| 1647 | - _moved_attributes += [MovedModule("winreg", "_winreg")] |
| 1648 | + _moved_attributes += [ |
| 1649 | + MovedModule("winreg", "_winreg"), |
| 1650 | + ] |
| 1651 | |
| 1652 | for attr in _moved_attributes: |
| 1653 | setattr(_MovedItems, attr.name, attr) |
| 1654 | @@ -476,7 +504,7 @@ class Module_six_moves_urllib_robotparser(_LazyModule): |
| 1655 | |
| 1656 | |
| 1657 | _urllib_robotparser_moved_attributes = [ |
| 1658 | - MovedAttribute("RobotFileParser", "robotparser", "urllib.robotparser") |
| 1659 | + MovedAttribute("RobotFileParser", "robotparser", "urllib.robotparser"), |
| 1660 | ] |
| 1661 | for attr in _urllib_robotparser_moved_attributes: |
| 1662 | setattr(Module_six_moves_urllib_robotparser, attr.name, attr) |
| 1663 | @@ -678,9 +706,11 @@ def u(s): |
| 1664 | if sys.version_info[1] <= 1: |
| 1665 | _assertRaisesRegex = "assertRaisesRegexp" |
| 1666 | _assertRegex = "assertRegexpMatches" |
| 1667 | + _assertNotRegex = "assertNotRegexpMatches" |
| 1668 | else: |
| 1669 | _assertRaisesRegex = "assertRaisesRegex" |
| 1670 | _assertRegex = "assertRegex" |
| 1671 | + _assertNotRegex = "assertNotRegex" |
| 1672 | else: |
| 1673 | |
| 1674 | def b(s): |
| 1675 | @@ -707,6 +737,7 @@ def indexbytes(buf, i): |
| 1676 | _assertCountEqual = "assertItemsEqual" |
| 1677 | _assertRaisesRegex = "assertRaisesRegexp" |
| 1678 | _assertRegex = "assertRegexpMatches" |
| 1679 | + _assertNotRegex = "assertNotRegexpMatches" |
| 1680 | _add_doc(b, """Byte literal""") |
| 1681 | _add_doc(u, """Text literal""") |
| 1682 | |
| 1683 | @@ -723,6 +754,10 @@ def assertRegex(self, *args, **kwargs): |
| 1684 | return getattr(self, _assertRegex)(*args, **kwargs) |
| 1685 | |
| 1686 | |
| 1687 | +def assertNotRegex(self, *args, **kwargs): |
| 1688 | + return getattr(self, _assertNotRegex)(*args, **kwargs) |
| 1689 | + |
| 1690 | + |
| 1691 | if PY3: |
| 1692 | exec_ = getattr(moves.builtins, "exec") |
| 1693 | |
| 1694 | @@ -737,7 +772,6 @@ def reraise(tp, value, tb=None): |
| 1695 | value = None |
| 1696 | tb = None |
| 1697 | |
| 1698 | - |
| 1699 | else: |
| 1700 | |
| 1701 | def exec_(_code_, _globs_=None, _locs_=None): |
| 1702 | @@ -750,7 +784,7 @@ def exec_(_code_, _globs_=None, _locs_=None): |
| 1703 | del frame |
| 1704 | elif _locs_ is None: |
| 1705 | _locs_ = _globs_ |
| 1706 | - exec("""exec _code_ in _globs_, _locs_""") |
| 1707 | + exec ("""exec _code_ in _globs_, _locs_""") |
| 1708 | |
| 1709 | exec_( |
| 1710 | """def reraise(tp, value, tb=None): |
| 1711 | @@ -762,18 +796,7 @@ def exec_(_code_, _globs_=None, _locs_=None): |
| 1712 | ) |
| 1713 | |
| 1714 | |
| 1715 | -if sys.version_info[:2] == (3, 2): |
| 1716 | - exec_( |
| 1717 | - """def raise_from(value, from_value): |
| 1718 | - try: |
| 1719 | - if from_value is None: |
| 1720 | - raise value |
| 1721 | - raise value from from_value |
| 1722 | - finally: |
| 1723 | - value = None |
| 1724 | -""" |
| 1725 | - ) |
| 1726 | -elif sys.version_info[:2] > (3, 2): |
| 1727 | +if sys.version_info[:2] > (3,): |
| 1728 | exec_( |
| 1729 | """def raise_from(value, from_value): |
| 1730 | try: |
| 1731 | @@ -863,19 +886,41 @@ def print_(*args, **kwargs): |
| 1732 | _add_doc(reraise, """Reraise an exception.""") |
| 1733 | |
| 1734 | if sys.version_info[0:2] < (3, 4): |
| 1735 | + # This does exactly the same what the :func:`py3:functools.update_wrapper` |
| 1736 | + # function does on Python versions after 3.2. It sets the ``__wrapped__`` |
| 1737 | + # attribute on ``wrapper`` object and it doesn't raise an error if any of |
| 1738 | + # the attributes mentioned in ``assigned`` and ``updated`` are missing on |
| 1739 | + # ``wrapped`` object. |
| 1740 | + def _update_wrapper( |
| 1741 | + wrapper, |
| 1742 | + wrapped, |
| 1743 | + assigned=functools.WRAPPER_ASSIGNMENTS, |
| 1744 | + updated=functools.WRAPPER_UPDATES, |
| 1745 | + ): |
| 1746 | + for attr in assigned: |
| 1747 | + try: |
| 1748 | + value = getattr(wrapped, attr) |
| 1749 | + except AttributeError: |
| 1750 | + continue |
| 1751 | + else: |
| 1752 | + setattr(wrapper, attr, value) |
| 1753 | + for attr in updated: |
| 1754 | + getattr(wrapper, attr).update(getattr(wrapped, attr, {})) |
| 1755 | + wrapper.__wrapped__ = wrapped |
| 1756 | + return wrapper |
| 1757 | + |
| 1758 | + _update_wrapper.__doc__ = functools.update_wrapper.__doc__ |
| 1759 | |
| 1760 | def wraps( |
| 1761 | wrapped, |
| 1762 | assigned=functools.WRAPPER_ASSIGNMENTS, |
| 1763 | updated=functools.WRAPPER_UPDATES, |
| 1764 | ): |
| 1765 | - def wrapper(f): |
| 1766 | - f = functools.wraps(wrapped, assigned, updated)(f) |
| 1767 | - f.__wrapped__ = wrapped |
| 1768 | - return f |
| 1769 | - |
| 1770 | - return wrapper |
| 1771 | + return functools.partial( |
| 1772 | + _update_wrapper, wrapped=wrapped, assigned=assigned, updated=updated |
| 1773 | + ) |
| 1774 | |
| 1775 | + wraps.__doc__ = functools.wraps.__doc__ |
| 1776 | |
| 1777 | else: |
| 1778 | wraps = functools.wraps |
| 1779 | @@ -888,7 +933,15 @@ def with_metaclass(meta, *bases): |
| 1780 | # the actual metaclass. |
| 1781 | class metaclass(type): |
| 1782 | def __new__(cls, name, this_bases, d): |
| 1783 | - return meta(name, bases, d) |
| 1784 | + if sys.version_info[:2] >= (3, 7): |
| 1785 | + # This version introduced PEP 560 that requires a bit |
| 1786 | + # of extra care (we mimic what is done by __build_class__). |
| 1787 | + resolved_bases = types.resolve_bases(bases) |
| 1788 | + if resolved_bases is not bases: |
| 1789 | + d["__orig_bases__"] = bases |
| 1790 | + else: |
| 1791 | + resolved_bases = bases |
| 1792 | + return meta(name, resolved_bases, d) |
| 1793 | |
| 1794 | @classmethod |
| 1795 | def __prepare__(cls, name, this_bases): |
| 1796 | @@ -928,12 +981,11 @@ def ensure_binary(s, encoding="utf-8", errors="strict"): |
| 1797 | - `str` -> encoded to `bytes` |
| 1798 | - `bytes` -> `bytes` |
| 1799 | """ |
| 1800 | + if isinstance(s, binary_type): |
| 1801 | + return s |
| 1802 | if isinstance(s, text_type): |
| 1803 | return s.encode(encoding, errors) |
| 1804 | - elif isinstance(s, binary_type): |
| 1805 | - return s |
| 1806 | - else: |
| 1807 | - raise TypeError("not expecting type '%s'" % type(s)) |
| 1808 | + raise TypeError("not expecting type '%s'" % type(s)) |
| 1809 | |
| 1810 | |
| 1811 | def ensure_str(s, encoding="utf-8", errors="strict"): |
| 1812 | @@ -947,12 +999,15 @@ def ensure_str(s, encoding="utf-8", errors="strict"): |
| 1813 | - `str` -> `str` |
| 1814 | - `bytes` -> decoded to `str` |
| 1815 | """ |
| 1816 | - if not isinstance(s, (text_type, binary_type)): |
| 1817 | - raise TypeError("not expecting type '%s'" % type(s)) |
| 1818 | + # Optimization: Fast return for the common case. |
| 1819 | + if type(s) is str: |
| 1820 | + return s |
| 1821 | if PY2 and isinstance(s, text_type): |
| 1822 | - s = s.encode(encoding, errors) |
| 1823 | + return s.encode(encoding, errors) |
| 1824 | elif PY3 and isinstance(s, binary_type): |
| 1825 | - s = s.decode(encoding, errors) |
| 1826 | + return s.decode(encoding, errors) |
| 1827 | + elif not isinstance(s, (text_type, binary_type)): |
| 1828 | + raise TypeError("not expecting type '%s'" % type(s)) |
| 1829 | return s |
| 1830 | |
| 1831 | |
| 1832 | @@ -977,7 +1032,7 @@ def ensure_text(s, encoding="utf-8", errors="strict"): |
| 1833 | |
| 1834 | def python_2_unicode_compatible(klass): |
| 1835 | """ |
| 1836 | - A decorator that defines __unicode__ and __str__ methods under Python 2. |
| 1837 | + A class decorator that defines __unicode__ and __str__ methods under Python 2. |
| 1838 | Under Python 3 it does nothing. |
| 1839 | |
| 1840 | To support Python 2 and 3 with a single code base, define a __str__ method |
| 1841 | diff --git a/third_party/python/urllib3/urllib3/packages/ssl_match_hostname/__init__.py b/third_party/python/urllib3/urllib3/packages/ssl_match_hostname/__init__.py |
| 1842 | deleted file mode 100644 |
| 1843 | index 6b12fd90aadec..0000000000000 |
| 1844 | --- a/third_party/python/urllib3/urllib3/packages/ssl_match_hostname/__init__.py |
| 1845 | +++ /dev/null |
| 1846 | @@ -1,22 +0,0 @@ |
| 1847 | -import sys |
| 1848 | - |
| 1849 | -try: |
| 1850 | - # Our match_hostname function is the same as 3.5's, so we only want to |
| 1851 | - # import the match_hostname function if it's at least that good. |
| 1852 | - if sys.version_info < (3, 5): |
| 1853 | - raise ImportError("Fallback to vendored code") |
| 1854 | - |
| 1855 | - from ssl import CertificateError, match_hostname |
| 1856 | -except ImportError: |
| 1857 | - try: |
| 1858 | - # Backport of the function from a pypi module |
| 1859 | - from backports.ssl_match_hostname import ( # type: ignore |
| 1860 | - CertificateError, |
| 1861 | - match_hostname, |
| 1862 | - ) |
| 1863 | - except ImportError: |
| 1864 | - # Our vendored copy |
| 1865 | - from ._implementation import CertificateError, match_hostname # type: ignore |
| 1866 | - |
| 1867 | -# Not needed, but documenting what we provide. |
| 1868 | -__all__ = ("CertificateError", "match_hostname") |
| 1869 | diff --git a/third_party/python/urllib3/urllib3/poolmanager.py b/third_party/python/urllib3/urllib3/poolmanager.py |
| 1870 | index 3a31a285bf648..14b10daf3a962 100644 |
| 1871 | --- a/third_party/python/urllib3/urllib3/poolmanager.py |
| 1872 | +++ b/third_party/python/urllib3/urllib3/poolmanager.py |
| 1873 | @@ -34,6 +34,7 @@ |
| 1874 | "ca_cert_dir", |
| 1875 | "ssl_context", |
| 1876 | "key_password", |
| 1877 | + "server_hostname", |
| 1878 | ) |
| 1879 | |
| 1880 | # All known keyword arguments that could be provided to the pool manager, its |
| 1881 | @@ -170,7 +171,7 @@ class PoolManager(RequestMethods): |
| 1882 | def __init__(self, num_pools=10, headers=None, **connection_pool_kw): |
| 1883 | RequestMethods.__init__(self, headers) |
| 1884 | self.connection_pool_kw = connection_pool_kw |
| 1885 | - self.pools = RecentlyUsedContainer(num_pools, dispose_func=lambda p: p.close()) |
| 1886 | + self.pools = RecentlyUsedContainer(num_pools) |
| 1887 | |
| 1888 | # Locally set the pool classes and keys so other PoolManagers can |
| 1889 | # override them. |
| 1890 | diff --git a/third_party/python/urllib3/urllib3/request.py b/third_party/python/urllib3/urllib3/request.py |
| 1891 | index 398386a5b9f61..3b4cf999225b8 100644 |
| 1892 | --- a/third_party/python/urllib3/urllib3/request.py |
| 1893 | +++ b/third_party/python/urllib3/urllib3/request.py |
| 1894 | @@ -1,6 +1,9 @@ |
| 1895 | from __future__ import absolute_import |
| 1896 | |
| 1897 | +import sys |
| 1898 | + |
| 1899 | from .filepost import encode_multipart_formdata |
| 1900 | +from .packages import six |
| 1901 | from .packages.six.moves.urllib.parse import urlencode |
| 1902 | |
| 1903 | __all__ = ["RequestMethods"] |
| 1904 | @@ -168,3 +171,21 @@ def request_encode_body( |
| 1905 | extra_kw.update(urlopen_kw) |
| 1906 | |
| 1907 | return self.urlopen(method, url, **extra_kw) |
| 1908 | + |
| 1909 | + |
| 1910 | +if not six.PY2: |
| 1911 | + |
| 1912 | + class RequestModule(sys.modules[__name__].__class__): |
| 1913 | + def __call__(self, *args, **kwargs): |
| 1914 | + """ |
| 1915 | + If user tries to call this module directly urllib3 v2.x style raise an error to the user |
| 1916 | + suggesting they may need urllib3 v2 |
| 1917 | + """ |
| 1918 | + raise TypeError( |
| 1919 | + "'module' object is not callable\n" |
| 1920 | + "urllib3.request() method is not supported in this release, " |
| 1921 | + "upgrade to urllib3 v2 to use it\n" |
| 1922 | + "see https://urllib3.readthedocs.io/en/stable/v2-migration-guide.html" |
| 1923 | + ) |
| 1924 | + |
| 1925 | + sys.modules[__name__].__class__ = RequestModule |
| 1926 | diff --git a/third_party/python/urllib3/urllib3/response.py b/third_party/python/urllib3/urllib3/response.py |
| 1927 | index 38693f4fc6e33..0bd13d40b8ac7 100644 |
| 1928 | --- a/third_party/python/urllib3/urllib3/response.py |
| 1929 | +++ b/third_party/python/urllib3/urllib3/response.py |
| 1930 | @@ -2,16 +2,22 @@ |
| 1931 | |
| 1932 | import io |
| 1933 | import logging |
| 1934 | +import sys |
| 1935 | +import warnings |
| 1936 | import zlib |
| 1937 | from contextlib import contextmanager |
| 1938 | from socket import error as SocketError |
| 1939 | from socket import timeout as SocketTimeout |
| 1940 | |
| 1941 | try: |
| 1942 | - import brotli |
| 1943 | + try: |
| 1944 | + import brotlicffi as brotli |
| 1945 | + except ImportError: |
| 1946 | + import brotli |
| 1947 | except ImportError: |
| 1948 | brotli = None |
| 1949 | |
| 1950 | +from . import util |
| 1951 | from ._collections import HTTPHeaderDict |
| 1952 | from .connection import BaseSSLError, HTTPException |
| 1953 | from .exceptions import ( |
| 1954 | @@ -478,6 +484,54 @@ def _error_catcher(self): |
| 1955 | if self._original_response and self._original_response.isclosed(): |
| 1956 | self.release_conn() |
| 1957 | |
| 1958 | + def _fp_read(self, amt): |
| 1959 | + """ |
| 1960 | + Read a response with the thought that reading the number of bytes |
| 1961 | + larger than can fit in a 32-bit int at a time via SSL in some |
| 1962 | + known cases leads to an overflow error that has to be prevented |
| 1963 | + if `amt` or `self.length_remaining` indicate that a problem may |
| 1964 | + happen. |
| 1965 | + |
| 1966 | + The known cases: |
| 1967 | + * 3.8 <= CPython < 3.9.7 because of a bug |
| 1968 | + https://github.com/urllib3/urllib3/issues/2513#issuecomment-1152559900. |
| 1969 | + * urllib3 injected with pyOpenSSL-backed SSL-support. |
| 1970 | + * CPython < 3.10 only when `amt` does not fit 32-bit int. |
| 1971 | + """ |
| 1972 | + assert self._fp |
| 1973 | + c_int_max = 2 ** 31 - 1 |
| 1974 | + if ( |
| 1975 | + ( |
| 1976 | + (amt and amt > c_int_max) |
| 1977 | + or (self.length_remaining and self.length_remaining > c_int_max) |
| 1978 | + ) |
| 1979 | + and not util.IS_SECURETRANSPORT |
| 1980 | + and (util.IS_PYOPENSSL or sys.version_info < (3, 10)) |
| 1981 | + ): |
| 1982 | + buffer = io.BytesIO() |
| 1983 | + # Besides `max_chunk_amt` being a maximum chunk size, it |
| 1984 | + # affects memory overhead of reading a response by this |
| 1985 | + # method in CPython. |
| 1986 | + # `c_int_max` equal to 2 GiB - 1 byte is the actual maximum |
| 1987 | + # chunk size that does not lead to an overflow error, but |
| 1988 | + # 256 MiB is a compromise. |
| 1989 | + max_chunk_amt = 2 ** 28 |
| 1990 | + while amt is None or amt != 0: |
| 1991 | + if amt is not None: |
| 1992 | + chunk_amt = min(amt, max_chunk_amt) |
| 1993 | + amt -= chunk_amt |
| 1994 | + else: |
| 1995 | + chunk_amt = max_chunk_amt |
| 1996 | + data = self._fp.read(chunk_amt) |
| 1997 | + if not data: |
| 1998 | + break |
| 1999 | + buffer.write(data) |
| 2000 | + del data # to reduce peak memory usage by `max_chunk_amt`. |
| 2001 | + return buffer.getvalue() |
| 2002 | + else: |
| 2003 | + # StringIO doesn't like amt=None |
| 2004 | + return self._fp.read(amt) if amt is not None else self._fp.read() |
| 2005 | + |
| 2006 | def read(self, amt=None, decode_content=None, cache_content=False): |
| 2007 | """ |
| 2008 | Similar to :meth:`http.client.HTTPResponse.read`, but with two additional |
| 2009 | @@ -510,13 +564,11 @@ def read(self, amt=None, decode_content=None, cache_content=False): |
| 2010 | fp_closed = getattr(self._fp, "closed", False) |
| 2011 | |
| 2012 | with self._error_catcher(): |
| 2013 | + data = self._fp_read(amt) if not fp_closed else b"" |
| 2014 | if amt is None: |
| 2015 | - # cStringIO doesn't like amt=None |
| 2016 | - data = self._fp.read() if not fp_closed else b"" |
| 2017 | flush_decoder = True |
| 2018 | else: |
| 2019 | cache_content = False |
| 2020 | - data = self._fp.read(amt) if not fp_closed else b"" |
| 2021 | if ( |
| 2022 | amt != 0 and not data |
| 2023 | ): # Platform-specific: Buggy versions of Python. |
| 2024 | @@ -612,9 +664,21 @@ def from_httplib(ResponseCls, r, **response_kw): |
| 2025 | |
| 2026 | # Backwards-compatibility methods for http.client.HTTPResponse |
| 2027 | def getheaders(self): |
| 2028 | + warnings.warn( |
| 2029 | + "HTTPResponse.getheaders() is deprecated and will be removed " |
| 2030 | + "in urllib3 v2.1.0. Instead access HTTPResponse.headers directly.", |
| 2031 | + category=DeprecationWarning, |
| 2032 | + stacklevel=2, |
| 2033 | + ) |
| 2034 | return self.headers |
| 2035 | |
| 2036 | def getheader(self, name, default=None): |
| 2037 | + warnings.warn( |
| 2038 | + "HTTPResponse.getheader() is deprecated and will be removed " |
| 2039 | + "in urllib3 v2.1.0. Instead use HTTPResponse.headers.get(name, default).", |
| 2040 | + category=DeprecationWarning, |
| 2041 | + stacklevel=2, |
| 2042 | + ) |
| 2043 | return self.headers.get(name, default) |
| 2044 | |
| 2045 | # Backwards compatibility for http.cookiejar |
| 2046 | diff --git a/third_party/python/urllib3/urllib3/util/connection.py b/third_party/python/urllib3/urllib3/util/connection.py |
| 2047 | index cd57455748be0..6af1138f260e4 100644 |
| 2048 | --- a/third_party/python/urllib3/urllib3/util/connection.py |
| 2049 | +++ b/third_party/python/urllib3/urllib3/util/connection.py |
| 2050 | @@ -2,9 +2,8 @@ |
| 2051 | |
| 2052 | import socket |
| 2053 | |
| 2054 | -from urllib3.exceptions import LocationParseError |
| 2055 | - |
| 2056 | from ..contrib import _appengine_environ |
| 2057 | +from ..exceptions import LocationParseError |
| 2058 | from ..packages import six |
| 2059 | from .wait import NoWayToWaitForSocketError, wait_for_read |
| 2060 | |
| 2061 | @@ -118,7 +117,7 @@ def allowed_gai_family(): |
| 2062 | |
| 2063 | |
| 2064 | def _has_ipv6(host): |
| 2065 | - """ Returns True if the system can bind an IPv6 address. """ |
| 2066 | + """Returns True if the system can bind an IPv6 address.""" |
| 2067 | sock = None |
| 2068 | has_ipv6 = False |
| 2069 | |
| 2070 | diff --git a/third_party/python/urllib3/urllib3/util/proxy.py b/third_party/python/urllib3/urllib3/util/proxy.py |
| 2071 | index 34f884d5b314d..2199cc7b7f004 100644 |
| 2072 | --- a/third_party/python/urllib3/urllib3/util/proxy.py |
| 2073 | +++ b/third_party/python/urllib3/urllib3/util/proxy.py |
| 2074 | @@ -45,6 +45,7 @@ def create_proxy_ssl_context( |
| 2075 | ssl_version=resolve_ssl_version(ssl_version), |
| 2076 | cert_reqs=resolve_cert_reqs(cert_reqs), |
| 2077 | ) |
| 2078 | + |
| 2079 | if ( |
| 2080 | not ca_certs |
| 2081 | and not ca_cert_dir |
| 2082 | diff --git a/third_party/python/urllib3/urllib3/util/request.py b/third_party/python/urllib3/urllib3/util/request.py |
| 2083 | index 25103383ec7ab..b574b081e98a0 100644 |
| 2084 | --- a/third_party/python/urllib3/urllib3/util/request.py |
| 2085 | +++ b/third_party/python/urllib3/urllib3/util/request.py |
| 2086 | @@ -14,7 +14,10 @@ |
| 2087 | |
| 2088 | ACCEPT_ENCODING = "gzip,deflate" |
| 2089 | try: |
| 2090 | - import brotli as _unused_module_brotli # noqa: F401 |
| 2091 | + try: |
| 2092 | + import brotlicffi as _unused_module_brotli # noqa: F401 |
| 2093 | + except ImportError: |
| 2094 | + import brotli as _unused_module_brotli # noqa: F401 |
| 2095 | except ImportError: |
| 2096 | pass |
| 2097 | else: |
| 2098 | diff --git a/third_party/python/urllib3/urllib3/util/retry.py b/third_party/python/urllib3/urllib3/util/retry.py |
| 2099 | index ee51f922f8452..60ef6c4f3f9d0 100644 |
| 2100 | --- a/third_party/python/urllib3/urllib3/util/retry.py |
| 2101 | +++ b/third_party/python/urllib3/urllib3/util/retry.py |
| 2102 | @@ -37,7 +37,7 @@ class _RetryMeta(type): |
| 2103 | def DEFAULT_METHOD_WHITELIST(cls): |
| 2104 | warnings.warn( |
| 2105 | "Using 'Retry.DEFAULT_METHOD_WHITELIST' is deprecated and " |
| 2106 | - "will be removed in v2.0. Use 'Retry.DEFAULT_METHODS_ALLOWED' instead", |
| 2107 | + "will be removed in v2.0. Use 'Retry.DEFAULT_ALLOWED_METHODS' instead", |
| 2108 | DeprecationWarning, |
| 2109 | ) |
| 2110 | return cls.DEFAULT_ALLOWED_METHODS |
| 2111 | @@ -69,6 +69,24 @@ def DEFAULT_REDIRECT_HEADERS_BLACKLIST(cls, value): |
| 2112 | ) |
| 2113 | cls.DEFAULT_REMOVE_HEADERS_ON_REDIRECT = value |
| 2114 | |
| 2115 | + @property |
| 2116 | + def BACKOFF_MAX(cls): |
| 2117 | + warnings.warn( |
| 2118 | + "Using 'Retry.BACKOFF_MAX' is deprecated and " |
| 2119 | + "will be removed in v2.0. Use 'Retry.DEFAULT_BACKOFF_MAX' instead", |
| 2120 | + DeprecationWarning, |
| 2121 | + ) |
| 2122 | + return cls.DEFAULT_BACKOFF_MAX |
| 2123 | + |
| 2124 | + @BACKOFF_MAX.setter |
| 2125 | + def BACKOFF_MAX(cls, value): |
| 2126 | + warnings.warn( |
| 2127 | + "Using 'Retry.BACKOFF_MAX' is deprecated and " |
| 2128 | + "will be removed in v2.0. Use 'Retry.DEFAULT_BACKOFF_MAX' instead", |
| 2129 | + DeprecationWarning, |
| 2130 | + ) |
| 2131 | + cls.DEFAULT_BACKOFF_MAX = value |
| 2132 | + |
| 2133 | |
| 2134 | @six.add_metaclass(_RetryMeta) |
| 2135 | class Retry(object): |
| 2136 | @@ -181,7 +199,7 @@ class Retry(object): |
| 2137 | |
| 2138 | seconds. If the backoff_factor is 0.1, then :func:`.sleep` will sleep |
| 2139 | for [0.0s, 0.2s, 0.4s, ...] between retries. It will never be longer |
| 2140 | - than :attr:`Retry.BACKOFF_MAX`. |
| 2141 | + than :attr:`Retry.DEFAULT_BACKOFF_MAX`. |
| 2142 | |
| 2143 | By default, backoff is disabled (set to 0). |
| 2144 | |
| 2145 | @@ -217,10 +235,10 @@ class Retry(object): |
| 2146 | RETRY_AFTER_STATUS_CODES = frozenset([413, 429, 503]) |
| 2147 | |
| 2148 | #: Default headers to be used for ``remove_headers_on_redirect`` |
| 2149 | - DEFAULT_REMOVE_HEADERS_ON_REDIRECT = frozenset(["Authorization"]) |
| 2150 | + DEFAULT_REMOVE_HEADERS_ON_REDIRECT = frozenset(["Cookie", "Authorization"]) |
| 2151 | |
| 2152 | #: Maximum backoff time. |
| 2153 | - BACKOFF_MAX = 120 |
| 2154 | + DEFAULT_BACKOFF_MAX = 120 |
| 2155 | |
| 2156 | def __init__( |
| 2157 | self, |
| 2158 | @@ -253,6 +271,7 @@ def __init__( |
| 2159 | "Using 'method_whitelist' with Retry is deprecated and " |
| 2160 | "will be removed in v2.0. Use 'allowed_methods' instead", |
| 2161 | DeprecationWarning, |
| 2162 | + stacklevel=2, |
| 2163 | ) |
| 2164 | allowed_methods = method_whitelist |
| 2165 | if allowed_methods is _Default: |
| 2166 | @@ -320,7 +339,7 @@ def new(self, **kw): |
| 2167 | |
| 2168 | @classmethod |
| 2169 | def from_int(cls, retries, redirect=True, default=None): |
| 2170 | - """ Backwards-compatibility for the old retries format.""" |
| 2171 | + """Backwards-compatibility for the old retries format.""" |
| 2172 | if retries is None: |
| 2173 | retries = default if default is not None else cls.DEFAULT |
| 2174 | |
| 2175 | @@ -347,7 +366,7 @@ def get_backoff_time(self): |
| 2176 | return 0 |
| 2177 | |
| 2178 | backoff_value = self.backoff_factor * (2 ** (consecutive_errors_len - 1)) |
| 2179 | - return min(self.BACKOFF_MAX, backoff_value) |
| 2180 | + return min(self.DEFAULT_BACKOFF_MAX, backoff_value) |
| 2181 | |
| 2182 | def parse_retry_after(self, retry_after): |
| 2183 | # Whitespace: https://tools.ietf.org/html/rfc7230#section-3.2.4 |
| 2184 | @@ -373,9 +392,9 @@ def parse_retry_after(self, retry_after): |
| 2185 | return seconds |
| 2186 | |
| 2187 | def get_retry_after(self, response): |
| 2188 | - """ Get the value of Retry-After in seconds. """ |
| 2189 | + """Get the value of Retry-After in seconds.""" |
| 2190 | |
| 2191 | - retry_after = response.getheader("Retry-After") |
| 2192 | + retry_after = response.headers.get("Retry-After") |
| 2193 | |
| 2194 | if retry_after is None: |
| 2195 | return None |
| 2196 | @@ -467,7 +486,7 @@ def is_retry(self, method, status_code, has_retry_after=False): |
| 2197 | ) |
| 2198 | |
| 2199 | def is_exhausted(self): |
| 2200 | - """ Are we out of retries? """ |
| 2201 | + """Are we out of retries?""" |
| 2202 | retry_counts = ( |
| 2203 | self.total, |
| 2204 | self.connect, |
| 2205 | diff --git a/third_party/python/urllib3/urllib3/util/ssl_.py b/third_party/python/urllib3/urllib3/util/ssl_.py |
| 2206 | index 1cb5e7cdc1c0c..8f867812a5eb3 100644 |
| 2207 | --- a/third_party/python/urllib3/urllib3/util/ssl_.py |
| 2208 | +++ b/third_party/python/urllib3/urllib3/util/ssl_.py |
| 2209 | @@ -44,13 +44,21 @@ def _const_compare_digest_backport(a, b): |
| 2210 | |
| 2211 | try: # Test for SSL features |
| 2212 | import ssl |
| 2213 | - from ssl import HAS_SNI # Has SNI? |
| 2214 | from ssl import CERT_REQUIRED, wrap_socket |
| 2215 | +except ImportError: |
| 2216 | + pass |
| 2217 | + |
| 2218 | +try: |
| 2219 | + from ssl import HAS_SNI # Has SNI? |
| 2220 | +except ImportError: |
| 2221 | + pass |
| 2222 | |
| 2223 | +try: |
| 2224 | from .ssltransport import SSLTransport |
| 2225 | except ImportError: |
| 2226 | pass |
| 2227 | |
| 2228 | + |
| 2229 | try: # Platform-specific: Python 3.6 |
| 2230 | from ssl import PROTOCOL_TLS |
| 2231 | |
| 2232 | @@ -63,6 +71,11 @@ def _const_compare_digest_backport(a, b): |
| 2233 | except ImportError: |
| 2234 | PROTOCOL_SSLv23 = PROTOCOL_TLS = 2 |
| 2235 | |
| 2236 | +try: |
| 2237 | + from ssl import PROTOCOL_TLS_CLIENT |
| 2238 | +except ImportError: |
| 2239 | + PROTOCOL_TLS_CLIENT = PROTOCOL_TLS |
| 2240 | + |
| 2241 | |
| 2242 | try: |
| 2243 | from ssl import OP_NO_COMPRESSION, OP_NO_SSLv2, OP_NO_SSLv3 |
| 2244 | @@ -151,7 +164,7 @@ def wrap_socket(self, socket, server_hostname=None, server_side=False): |
| 2245 | "urllib3 from configuring SSL appropriately and may cause " |
| 2246 | "certain SSL connections to fail. You can upgrade to a newer " |
| 2247 | "version of Python to solve this. For more information, see " |
| 2248 | - "https://urllib3.readthedocs.io/en/latest/advanced-usage.html" |
| 2249 | + "https://urllib3.readthedocs.io/en/1.26.x/advanced-usage.html" |
| 2250 | "#ssl-warnings", |
| 2251 | InsecurePlatformWarning, |
| 2252 | ) |
| 2253 | @@ -270,7 +283,11 @@ def create_urllib3_context( |
| 2254 | Constructed SSLContext object with specified options |
| 2255 | :rtype: SSLContext |
| 2256 | """ |
| 2257 | - context = SSLContext(ssl_version or PROTOCOL_TLS) |
| 2258 | + # PROTOCOL_TLS is deprecated in Python 3.10 |
| 2259 | + if not ssl_version or ssl_version == PROTOCOL_TLS: |
| 2260 | + ssl_version = PROTOCOL_TLS_CLIENT |
| 2261 | + |
| 2262 | + context = SSLContext(ssl_version) |
| 2263 | |
| 2264 | context.set_ciphers(ciphers or DEFAULT_CIPHERS) |
| 2265 | |
| 2266 | @@ -305,13 +322,25 @@ def create_urllib3_context( |
| 2267 | ) is not None: |
| 2268 | context.post_handshake_auth = True |
| 2269 | |
| 2270 | - context.verify_mode = cert_reqs |
| 2271 | - if ( |
| 2272 | - getattr(context, "check_hostname", None) is not None |
| 2273 | - ): # Platform-specific: Python 3.2 |
| 2274 | - # We do our own verification, including fingerprints and alternative |
| 2275 | - # hostnames. So disable it here |
| 2276 | - context.check_hostname = False |
| 2277 | + def disable_check_hostname(): |
| 2278 | + if ( |
| 2279 | + getattr(context, "check_hostname", None) is not None |
| 2280 | + ): # Platform-specific: Python 3.2 |
| 2281 | + # We do our own verification, including fingerprints and alternative |
| 2282 | + # hostnames. So disable it here |
| 2283 | + context.check_hostname = False |
| 2284 | + |
| 2285 | + # The order of the below lines setting verify_mode and check_hostname |
| 2286 | + # matter due to safe-guards SSLContext has to prevent an SSLContext with |
| 2287 | + # check_hostname=True, verify_mode=NONE/OPTIONAL. This is made even more |
| 2288 | + # complex because we don't know whether PROTOCOL_TLS_CLIENT will be used |
| 2289 | + # or not so we don't know the initial state of the freshly created SSLContext. |
| 2290 | + if cert_reqs == ssl.CERT_REQUIRED: |
| 2291 | + context.verify_mode = cert_reqs |
| 2292 | + disable_check_hostname() |
| 2293 | + else: |
| 2294 | + disable_check_hostname() |
| 2295 | + context.verify_mode = cert_reqs |
| 2296 | |
| 2297 | # Enable logging of TLS session keys via defacto standard environment variable |
| 2298 | # 'SSLKEYLOGFILE', if the feature is available (Python 3.8+). Skip empty values. |
| 2299 | @@ -393,7 +422,7 @@ def ssl_wrap_socket( |
| 2300 | try: |
| 2301 | if hasattr(context, "set_alpn_protocols"): |
| 2302 | context.set_alpn_protocols(ALPN_PROTOCOLS) |
| 2303 | - except NotImplementedError: |
| 2304 | + except NotImplementedError: # Defensive: in CI, we always have set_alpn_protocols |
| 2305 | pass |
| 2306 | |
| 2307 | # If we detect server_hostname is an IP address then the SNI |
| 2308 | @@ -411,7 +440,7 @@ def ssl_wrap_socket( |
| 2309 | "This may cause the server to present an incorrect TLS " |
| 2310 | "certificate, which can cause validation failures. You can upgrade to " |
| 2311 | "a newer version of Python to solve this. For more information, see " |
| 2312 | - "https://urllib3.readthedocs.io/en/latest/advanced-usage.html" |
| 2313 | + "https://urllib3.readthedocs.io/en/1.26.x/advanced-usage.html" |
| 2314 | "#ssl-warnings", |
| 2315 | SNIMissingWarning, |
| 2316 | ) |
| 2317 | diff --git a/third_party/python/urllib3/urllib3/packages/ssl_match_hostname/_implementation.py b/third_party/python/urllib3/urllib3/util/ssl_match_hostname.py |
| 2318 | similarity index 92% |
| 2319 | rename from third_party/python/urllib3/urllib3/packages/ssl_match_hostname/_implementation.py |
| 2320 | rename to third_party/python/urllib3/urllib3/util/ssl_match_hostname.py |
| 2321 | index 689208d3c63f1..1dd950c489607 100644 |
| 2322 | --- a/third_party/python/urllib3/urllib3/packages/ssl_match_hostname/_implementation.py |
| 2323 | +++ b/third_party/python/urllib3/urllib3/util/ssl_match_hostname.py |
| 2324 | @@ -9,7 +9,7 @@ |
| 2325 | # ipaddress has been backported to 2.6+ in pypi. If it is installed on the |
| 2326 | # system, use it to handle IPAddress ServerAltnames (this was added in |
| 2327 | # python-3.5) otherwise only do DNS matching. This allows |
| 2328 | -# backports.ssl_match_hostname to continue to be used in Python 2.7. |
| 2329 | +# util.ssl_match_hostname to continue to be used in Python 2.7. |
| 2330 | try: |
| 2331 | import ipaddress |
| 2332 | except ImportError: |
| 2333 | @@ -78,7 +78,8 @@ def _dnsname_match(dn, hostname, max_wildcards=1): |
| 2334 | |
| 2335 | def _to_unicode(obj): |
| 2336 | if isinstance(obj, str) and sys.version_info < (3,): |
| 2337 | - obj = unicode(obj, encoding="ascii", errors="strict") |
| 2338 | + # ignored flake8 # F821 to support python 2.7 function |
| 2339 | + obj = unicode(obj, encoding="ascii", errors="strict") # noqa: F821 |
| 2340 | return obj |
| 2341 | |
| 2342 | |
| 2343 | @@ -111,11 +112,9 @@ def match_hostname(cert, hostname): |
| 2344 | try: |
| 2345 | # Divergence from upstream: ipaddress can't handle byte str |
| 2346 | host_ip = ipaddress.ip_address(_to_unicode(hostname)) |
| 2347 | - except ValueError: |
| 2348 | - # Not an IP address (common case) |
| 2349 | - host_ip = None |
| 2350 | - except UnicodeError: |
| 2351 | - # Divergence from upstream: Have to deal with ipaddress not taking |
| 2352 | + except (UnicodeError, ValueError): |
| 2353 | + # ValueError: Not an IP address (common case) |
| 2354 | + # UnicodeError: Divergence from upstream: Have to deal with ipaddress not taking |
| 2355 | # byte strings. addresses should be all ascii, so we consider it not |
| 2356 | # an ipaddress in this case |
| 2357 | host_ip = None |
| 2358 | @@ -123,7 +122,7 @@ def match_hostname(cert, hostname): |
| 2359 | # Divergence from upstream: Make ipaddress library optional |
| 2360 | if ipaddress is None: |
| 2361 | host_ip = None |
| 2362 | - else: |
| 2363 | + else: # Defensive |
| 2364 | raise |
| 2365 | dnsnames = [] |
| 2366 | san = cert.get("subjectAltName", ()) |
| 2367 | diff --git a/third_party/python/urllib3/urllib3/util/ssltransport.py b/third_party/python/urllib3/urllib3/util/ssltransport.py |
| 2368 | index 1e41354f5d458..4a7105d17916a 100644 |
| 2369 | --- a/third_party/python/urllib3/urllib3/util/ssltransport.py |
| 2370 | +++ b/third_party/python/urllib3/urllib3/util/ssltransport.py |
| 2371 | @@ -2,8 +2,8 @@ |
| 2372 | import socket |
| 2373 | import ssl |
| 2374 | |
| 2375 | -from urllib3.exceptions import ProxySchemeUnsupported |
| 2376 | -from urllib3.packages import six |
| 2377 | +from ..exceptions import ProxySchemeUnsupported |
| 2378 | +from ..packages import six |
| 2379 | |
| 2380 | SSL_BLOCKSIZE = 16384 |
| 2381 | |
| 2382 | @@ -193,7 +193,7 @@ def _wrap_ssl_read(self, len, buffer=None): |
| 2383 | raise |
| 2384 | |
| 2385 | def _ssl_io_loop(self, func, *args): |
| 2386 | - """ Performs an I/O loop between incoming/outgoing and the socket.""" |
| 2387 | + """Performs an I/O loop between incoming/outgoing and the socket.""" |
| 2388 | should_loop = True |
| 2389 | ret = None |
| 2390 | |
| 2391 | diff --git a/third_party/python/urllib3/urllib3/util/timeout.py b/third_party/python/urllib3/urllib3/util/timeout.py |
| 2392 | index ff69593b05b5e..78e18a6272482 100644 |
| 2393 | --- a/third_party/python/urllib3/urllib3/util/timeout.py |
| 2394 | +++ b/third_party/python/urllib3/urllib3/util/timeout.py |
| 2395 | @@ -2,9 +2,8 @@ |
| 2396 | |
| 2397 | import time |
| 2398 | |
| 2399 | -# The default socket timeout, used by httplib to indicate that no timeout was |
| 2400 | -# specified by the user |
| 2401 | -from socket import _GLOBAL_DEFAULT_TIMEOUT |
| 2402 | +# The default socket timeout, used by httplib to indicate that no timeout was; specified by the user |
| 2403 | +from socket import _GLOBAL_DEFAULT_TIMEOUT, getdefaulttimeout |
| 2404 | |
| 2405 | from ..exceptions import TimeoutStateError |
| 2406 | |
| 2407 | @@ -116,6 +115,10 @@ def __repr__(self): |
| 2408 | # __str__ provided for backwards compatibility |
| 2409 | __str__ = __repr__ |
| 2410 | |
| 2411 | + @classmethod |
| 2412 | + def resolve_default_timeout(cls, timeout): |
| 2413 | + return getdefaulttimeout() if timeout is cls.DEFAULT_TIMEOUT else timeout |
| 2414 | + |
| 2415 | @classmethod |
| 2416 | def _validate_timeout(cls, value, name): |
| 2417 | """Check that a timeout attribute is valid. |
| 2418 | diff --git a/third_party/python/urllib3/urllib3/util/url.py b/third_party/python/urllib3/urllib3/util/url.py |
| 2419 | index 6ff238fe3cbd0..e5682d3be4293 100644 |
| 2420 | --- a/third_party/python/urllib3/urllib3/util/url.py |
| 2421 | +++ b/third_party/python/urllib3/urllib3/util/url.py |
| 2422 | @@ -50,7 +50,7 @@ |
| 2423 | "(?:(?:%(hex)s:){0,6}%(hex)s)?::", |
| 2424 | ] |
| 2425 | |
| 2426 | -UNRESERVED_PAT = r"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789._!\-~" |
| 2427 | +UNRESERVED_PAT = r"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789._\-~" |
| 2428 | IPV6_PAT = "(?:" + "|".join([x % _subs for x in _variations]) + ")" |
| 2429 | ZONE_ID_PAT = "(?:%25|%)(?:[" + UNRESERVED_PAT + "]|%[a-fA-F0-9]{2})+" |
| 2430 | IPV6_ADDRZ_PAT = r"\[" + IPV6_PAT + r"(?:" + ZONE_ID_PAT + r")?\]" |
| 2431 | @@ -63,12 +63,12 @@ |
| 2432 | BRACELESS_IPV6_ADDRZ_RE = re.compile("^" + IPV6_ADDRZ_PAT[2:-2] + "$") |
| 2433 | ZONE_ID_RE = re.compile("(" + ZONE_ID_PAT + r")\]$") |
| 2434 | |
| 2435 | -SUBAUTHORITY_PAT = (u"^(?:(.*)@)?(%s|%s|%s)(?::([0-9]{0,5}))?$") % ( |
| 2436 | +_HOST_PORT_PAT = ("^(%s|%s|%s)(?::0*?(|0|[1-9][0-9]{0,4}))?$") % ( |
| 2437 | REG_NAME_PAT, |
| 2438 | IPV4_PAT, |
| 2439 | IPV6_ADDRZ_PAT, |
| 2440 | ) |
| 2441 | -SUBAUTHORITY_RE = re.compile(SUBAUTHORITY_PAT, re.UNICODE | re.DOTALL) |
| 2442 | +_HOST_PORT_RE = re.compile(_HOST_PORT_PAT, re.UNICODE | re.DOTALL) |
| 2443 | |
| 2444 | UNRESERVED_CHARS = set( |
| 2445 | "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789._-~" |
| 2446 | @@ -279,6 +279,9 @@ def _normalize_host(host, scheme): |
| 2447 | if scheme in NORMALIZABLE_SCHEMES: |
| 2448 | is_ipv6 = IPV6_ADDRZ_RE.match(host) |
| 2449 | if is_ipv6: |
| 2450 | + # IPv6 hosts of the form 'a::b%zone' are encoded in a URL as |
| 2451 | + # such per RFC 6874: 'a::b%25zone'. Unquote the ZoneID |
| 2452 | + # separator as necessary to return a valid RFC 4007 scoped IP. |
| 2453 | match = ZONE_ID_RE.search(host) |
| 2454 | if match: |
| 2455 | start, end = match.span(1) |
| 2456 | @@ -300,7 +303,7 @@ def _normalize_host(host, scheme): |
| 2457 | |
| 2458 | |
| 2459 | def _idna_encode(name): |
| 2460 | - if name and any([ord(x) > 128 for x in name]): |
| 2461 | + if name and any(ord(x) >= 128 for x in name): |
| 2462 | try: |
| 2463 | import idna |
| 2464 | except ImportError: |
| 2465 | @@ -331,7 +334,7 @@ def parse_url(url): |
| 2466 | """ |
| 2467 | Given a url, return a parsed :class:`.Url` namedtuple. Best-effort is |
| 2468 | performed to parse incomplete urls. Fields not provided will be None. |
| 2469 | - This parser is RFC 3986 compliant. |
| 2470 | + This parser is RFC 3986 and RFC 6874 compliant. |
| 2471 | |
| 2472 | The parser logic and helper functions are based heavily on |
| 2473 | work done in the ``rfc3986`` module. |
| 2474 | @@ -365,7 +368,9 @@ def parse_url(url): |
| 2475 | scheme = scheme.lower() |
| 2476 | |
| 2477 | if authority: |
| 2478 | - auth, host, port = SUBAUTHORITY_RE.match(authority).groups() |
| 2479 | + auth, _, host_port = authority.rpartition("@") |
| 2480 | + auth = auth or None |
| 2481 | + host, port = _HOST_PORT_RE.match(host_port).groups() |
| 2482 | if auth and normalize_uri: |
| 2483 | auth = _encode_invalid_chars(auth, USERINFO_CHARS) |
| 2484 | if port == "": |
| 2485 | diff --git a/third_party/python/urllib3/urllib3/util/wait.py b/third_party/python/urllib3/urllib3/util/wait.py |
| 2486 | index c280646c7be0b..21b4590b3dc9b 100644 |
| 2487 | --- a/third_party/python/urllib3/urllib3/util/wait.py |
| 2488 | +++ b/third_party/python/urllib3/urllib3/util/wait.py |
| 2489 | @@ -42,7 +42,6 @@ class NoWayToWaitForSocketError(Exception): |
| 2490 | def _retry_on_intr(fn, timeout): |
| 2491 | return fn(timeout) |
| 2492 | |
| 2493 | - |
| 2494 | else: |
| 2495 | # Old and broken Pythons. |
| 2496 | def _retry_on_intr(fn, timeout): |