Skip to content

Commit c8e8a99

Browse files
authored
Upgrade Dependencies (#4038)
* Upgrade distlib to 0.2.4 * Upgrade distro to 1.0.0 * Upgrade html5lib to 1.0b10 * Upgrade requests to 2.11.1 * Upgrade CacheControl to 0.11.7 * Upgrade ipaddress to 1.0.17 * Upgrade pyparsing to 2.1.10 * Upgrade packaging to 16.8 * Add webencodings 0.5 * Add ordereddict 1.1
1 parent 22f2e01 commit c8e8a99

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

96 files changed

+7077
-2557
lines changed

pip/_vendor/README.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ Modifications
106106
* CacheControl has been modified to import its dependencies from pip._vendor
107107
* packaging has been modified to import its dependencies from pip._vendor
108108
* requests has been modified *not* to optionally load any C dependencies.
109+
* Modified distro to delay importing argparse to avoid errors on 2.6
109110

110111

111112
Debundling

pip/_vendor/cachecontrol/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"""
55
__author__ = 'Eric Larson'
66
__email__ = '[email protected]'
7-
__version__ = '0.11.6'
7+
__version__ = '0.11.7'
88

99
from .wrapper import CacheControl
1010
from .adapter import CacheControlAdapter

pip/_vendor/cachecontrol/adapter.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import types
12
import functools
23

34
from pip._vendor.requests.adapters import HTTPAdapter
@@ -55,6 +56,10 @@ def build_response(self, request, response, from_cache=False):
5556
cached response
5657
"""
5758
if not from_cache and request.method == 'GET':
59+
# Check for any heuristics that might update headers
60+
# before trying to cache.
61+
if self.heuristic:
62+
response = self.heuristic.apply(response)
5863

5964
# apply any expiration heuristics
6065
if response.status == 304:
@@ -82,11 +87,6 @@ def build_response(self, request, response, from_cache=False):
8287
elif response.status == 301:
8388
self.controller.cache_response(request, response)
8489
else:
85-
# Check for any heuristics that might update headers
86-
# before trying to cache.
87-
if self.heuristic:
88-
response = self.heuristic.apply(response)
89-
9090
# Wrap the response file with a wrapper that will cache the
9191
# response when the stream has been consumed.
9292
response._fp = CallbackFileWrapper(
@@ -97,6 +97,14 @@ def build_response(self, request, response, from_cache=False):
9797
response,
9898
)
9999
)
100+
if response.chunked:
101+
super_update_chunk_length = response._update_chunk_length
102+
103+
def _update_chunk_length(self):
104+
super_update_chunk_length()
105+
if self.chunk_left == 0:
106+
self._fp._close()
107+
response._update_chunk_length = types.MethodType(_update_chunk_length, response)
100108

101109
resp = super(CacheControlAdapter, self).build_response(
102110
request, response

pip/_vendor/cachecontrol/controller.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ def cache_response(self, request, response, body=None):
290290
elif 'date' in response_headers:
291291
# cache when there is a max-age > 0
292292
if cc and cc.get('max-age'):
293-
if int(cc['max-age']) > 0:
293+
if cc['max-age'].isdigit() and int(cc['max-age']) > 0:
294294
logger.debug('Caching b/c date exists and max-age > 0')
295295
self.cache.set(
296296
cache_url,

pip/_vendor/cachecontrol/filewrapper.py

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,19 +45,34 @@ def __is_fp_closed(self):
4545
# TODO: Add some logging here...
4646
return False
4747

48+
def _close(self):
49+
if self.__callback:
50+
self.__callback(self.__buf.getvalue())
51+
52+
# We assign this to None here, because otherwise we can get into
53+
# really tricky problems where the CPython interpreter dead locks
54+
# because the callback is holding a reference to something which
55+
# has a __del__ method. Setting this to None breaks the cycle
56+
# and allows the garbage collector to do it's thing normally.
57+
self.__callback = None
58+
4859
def read(self, amt=None):
4960
data = self.__fp.read(amt)
5061
self.__buf.write(data)
62+
if self.__is_fp_closed():
63+
self._close()
5164

65+
return data
66+
67+
def _safe_read(self, amt):
68+
data = self.__fp._safe_read(amt)
69+
if amt == 2 and data == b'\r\n':
70+
# urllib executes this read to toss the CRLF at the end
71+
# of the chunk.
72+
return data
73+
74+
self.__buf.write(data)
5275
if self.__is_fp_closed():
53-
if self.__callback:
54-
self.__callback(self.__buf.getvalue())
55-
56-
# We assign this to None here, because otherwise we can get into
57-
# really tricky problems where the CPython interpreter dead locks
58-
# because the callback is holding a reference to something which
59-
# has a __del__ method. Setting this to None breaks the cycle
60-
# and allows the garbage collector to do it's thing normally.
61-
self.__callback = None
76+
self._close()
6277

6378
return data

pip/_vendor/cachecontrol/serialize.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,12 @@ def prepare_response(self, request, cached):
134134

135135
body_raw = cached["response"].pop("body")
136136

137+
headers = CaseInsensitiveDict(data=cached['response']['headers'])
138+
if headers.get('transfer-encoding', '') == 'chunked':
139+
headers.pop('transfer-encoding')
140+
141+
cached['response']['headers'] = headers
142+
137143
try:
138144
body = io.BytesIO(body_raw)
139145
except TypeError:

pip/_vendor/distlib/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#
77
import logging
88

9-
__version__ = '0.2.3'
9+
__version__ = '0.2.4'
1010

1111
class DistlibException(Exception):
1212
pass

pip/_vendor/distlib/_backport/shutil.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ class ReadError(EnvironmentError):
5555
"""Raised when an archive cannot be read"""
5656

5757
class RegistryError(Exception):
58-
"""Raised when a registery operation with the archiving
59-
and unpacking registeries fails"""
58+
"""Raised when a registry operation with the archiving
59+
and unpacking registries fails"""
6060

6161

6262
try:
@@ -648,7 +648,7 @@ def register_unpack_format(name, extensions, function, extra_args=None,
648648
_UNPACK_FORMATS[name] = extensions, function, extra_args, description
649649

650650
def unregister_unpack_format(name):
651-
"""Removes the pack format from the registery."""
651+
"""Removes the pack format from the registry."""
652652
del _UNPACK_FORMATS[name]
653653

654654
def _ensure_directory(path):

pip/_vendor/distlib/_backport/tarfile.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ class ExtractError(TarError):
331331
"""General exception for extract errors."""
332332
pass
333333
class ReadError(TarError):
334-
"""Exception for unreadble tar archives."""
334+
"""Exception for unreadable tar archives."""
335335
pass
336336
class CompressionError(TarError):
337337
"""Exception for unavailable compression methods."""

pip/_vendor/distlib/compat.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@
1010
import re
1111
import sys
1212

13+
try:
14+
import ssl
15+
except ImportError:
16+
ssl = None
17+
1318
if sys.version_info[0] < 3: # pragma: no cover
1419
from StringIO import StringIO
1520
string_types = basestring,
@@ -30,8 +35,10 @@ def quote(s):
3035
import urllib2
3136
from urllib2 import (Request, urlopen, URLError, HTTPError,
3237
HTTPBasicAuthHandler, HTTPPasswordMgr,
33-
HTTPSHandler, HTTPHandler, HTTPRedirectHandler,
38+
HTTPHandler, HTTPRedirectHandler,
3439
build_opener)
40+
if ssl:
41+
from urllib2 import HTTPSHandler
3542
import httplib
3643
import xmlrpclib
3744
import Queue as queue
@@ -66,8 +73,10 @@ def splituser(host):
6673
from urllib.request import (urlopen, urlretrieve, Request, url2pathname,
6774
pathname2url,
6875
HTTPBasicAuthHandler, HTTPPasswordMgr,
69-
HTTPSHandler, HTTPHandler, HTTPRedirectHandler,
76+
HTTPHandler, HTTPRedirectHandler,
7077
build_opener)
78+
if ssl:
79+
from urllib.request import HTTPSHandler
7180
from urllib.error import HTTPError, URLError, ContentTooShortError
7281
import http.client as httplib
7382
import urllib.request as urllib2
@@ -101,7 +110,7 @@ def _dnsname_match(dn, hostname, max_wildcards=1):
101110
wildcards = leftmost.count('*')
102111
if wildcards > max_wildcards:
103112
# Issue #17980: avoid denials of service by refusing more
104-
# than one wildcard per fragment. A survery of established
113+
# than one wildcard per fragment. A survey of established
105114
# policy among SSL implementations showed it to be a
106115
# reasonable choice.
107116
raise CertificateError(
@@ -366,7 +375,7 @@ def _get_normal_name(orig_enc):
366375
def detect_encoding(readline):
367376
"""
368377
The detect_encoding() function is used to detect the encoding that should
369-
be used to decode a Python source file. It requires one argment, readline,
378+
be used to decode a Python source file. It requires one argument, readline,
370379
in the same way as the tokenize() generator.
371380
372381
It will call readline a maximum of twice, and return the encoding used

pip/_vendor/distlib/database.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1308,5 +1308,5 @@ def make_dist(name, version, **kwargs):
13081308
md = Metadata(**kwargs)
13091309
md.name = name
13101310
md.version = version
1311-
md.summary = summary or 'Plaeholder for summary'
1311+
md.summary = summary or 'Placeholder for summary'
13121312
return Distribution(md)

pip/_vendor/distlib/index.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,9 @@ def __init__(self, url=None):
5151
self.gpg_home = None
5252
self.rpc_proxy = None
5353
with open(os.devnull, 'w') as sink:
54-
for s in ('gpg2', 'gpg'):
54+
# Use gpg by default rather than gpg2, as gpg2 insists on
55+
# prompting for passwords
56+
for s in ('gpg', 'gpg2'):
5557
try:
5658
rc = subprocess.check_call([s, '--version'], stdout=sink,
5759
stderr=sink)
@@ -74,7 +76,7 @@ def _get_pypirc_command(self):
7476
def read_configuration(self):
7577
"""
7678
Read the PyPI access configuration as supported by distutils, getting
77-
PyPI to do the acutal work. This populates ``username``, ``password``,
79+
PyPI to do the actual work. This populates ``username``, ``password``,
7880
``realm`` and ``url`` attributes from the configuration.
7981
"""
8082
# get distutils to do the work
@@ -276,7 +278,7 @@ def upload_file(self, metadata, filename, signer=None, sign_password=None,
276278
sha256_digest = hashlib.sha256(file_data).hexdigest()
277279
d.update({
278280
':action': 'file_upload',
279-
'protcol_version': '1',
281+
'protocol_version': '1',
280282
'filetype': filetype,
281283
'pyversion': pyversion,
282284
'md5_digest': md5_digest,

pip/_vendor/distlib/locators.py

Lines changed: 30 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@
2121
from . import DistlibException
2222
from .compat import (urljoin, urlparse, urlunparse, url2pathname, pathname2url,
2323
queue, quote, unescape, string_types, build_opener,
24-
HTTPRedirectHandler as BaseRedirectHandler,
24+
HTTPRedirectHandler as BaseRedirectHandler, text_type,
2525
Request, HTTPError, URLError)
2626
from .database import Distribution, DistributionPath, make_dist
2727
from .metadata import Metadata
2828
from .util import (cached_property, parse_credentials, ensure_slash,
2929
split_filename, get_project_data, parse_requirement,
30-
parse_name_and_version, ServerProxy)
30+
parse_name_and_version, ServerProxy, normalize_name)
3131
from .version import get_scheme, UnsupportedVersionError
3232
from .wheel import Wheel, is_compatible
3333

@@ -113,6 +113,28 @@ def __init__(self, scheme='default'):
113113
# is set from the requirement passed to locate(). See issue #18 for
114114
# why this can be useful to know.
115115
self.matcher = None
116+
self.errors = queue.Queue()
117+
118+
def get_errors(self):
119+
"""
120+
Return any errors which have occurred.
121+
"""
122+
result = []
123+
while not self.errors.empty(): # pragma: no cover
124+
try:
125+
e = self.errors.get(False)
126+
result.append(e)
127+
except self.errors.Empty:
128+
continue
129+
self.errors.task_done()
130+
return result
131+
132+
def clear_errors(self):
133+
"""
134+
Clear any errors which may have been logged.
135+
"""
136+
# Just get the errors and throw them away
137+
self.get_errors()
116138

117139
def clear_cache(self):
118140
self._cache.clear()
@@ -155,6 +177,7 @@ def get_project(self, name):
155177
elif name in self._cache:
156178
result = self._cache[name]
157179
else:
180+
self.clear_errors()
158181
result = self._get_project(name)
159182
self._cache[name] = result
160183
return result
@@ -210,14 +233,7 @@ def convert_url_to_download_info(self, url, project_name):
210233
"filename" and "url"; otherwise, None is returned.
211234
"""
212235
def same_project(name1, name2):
213-
name1, name2 = name1.lower(), name2.lower()
214-
if name1 == name2:
215-
result = True
216-
else:
217-
# distribute replaces '-' by '_' in project names, so it
218-
# can tell where the version starts in a filename.
219-
result = name1.replace('_', '-') == name2.replace('_', '-')
220-
return result
236+
return normalize_name(name1) == normalize_name(name2)
221237

222238
result = None
223239
scheme, netloc, path, params, query, frag = urlparse(url)
@@ -250,7 +266,7 @@ def same_project(name1, name2):
250266
'python-version': ', '.join(
251267
['.'.join(list(v[2:])) for v in wheel.pyver]),
252268
}
253-
except Exception as e:
269+
except Exception as e: # pragma: no cover
254270
logger.warning('invalid path for wheel: %s', path)
255271
elif path.endswith(self.downloadable_extensions):
256272
path = filename = posixpath.basename(path)
@@ -489,6 +505,7 @@ def _get_project(self, name):
489505
# result['urls'].setdefault(md.version, set()).add(url)
490506
# result['digests'][url] = self._get_digest(info)
491507
except Exception as e:
508+
self.errors.put(text_type(e))
492509
logger.exception('JSON fetch failed: %s', e)
493510
return result
494511

@@ -714,6 +731,8 @@ def _fetch(self):
714731
self._should_queue(link, url, rel)):
715732
logger.debug('Queueing %s from %s', link, url)
716733
self._to_fetch.put(link)
734+
except Exception as e: # pragma: no cover
735+
self.errors.put(text_type(e))
717736
finally:
718737
# always do this, to avoid hangs :-)
719738
self._to_fetch.task_done()

0 commit comments

Comments
 (0)