Skip to content

Commit 89917c9

Browse files
committed
Merge pull request #2469 from Gillingham/update-to-requests-2.5.3
Upgrade requests to 2.5.3
2 parents 540bc21 + d2d111d commit 89917c9

16 files changed

+459
-199
lines changed

pip/_vendor/requests/__init__.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -36,17 +36,17 @@
3636
The other HTTP methods are supported - see `requests.api`. Full documentation
3737
is at <http://python-requests.org>.
3838
39-
:copyright: (c) 2014 by Kenneth Reitz.
39+
:copyright: (c) 2015 by Kenneth Reitz.
4040
:license: Apache 2.0, see LICENSE for more details.
4141
4242
"""
4343

4444
__title__ = 'requests'
45-
__version__ = '2.5.1'
46-
__build__ = 0x020501
45+
__version__ = '2.5.3'
46+
__build__ = 0x020503
4747
__author__ = 'Kenneth Reitz'
4848
__license__ = 'Apache 2.0'
49-
__copyright__ = 'Copyright 2014 Kenneth Reitz'
49+
__copyright__ = 'Copyright 2015 Kenneth Reitz'
5050

5151
# Attempt to enable urllib3's SNI support, if possible
5252
try:

pip/_vendor/requests/auth.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -124,13 +124,15 @@ def sha_utf8(x):
124124
s += os.urandom(8)
125125

126126
cnonce = (hashlib.sha1(s).hexdigest()[:16])
127-
noncebit = "%s:%s:%s:%s:%s" % (nonce, ncvalue, cnonce, qop, HA2)
128127
if _algorithm == 'MD5-SESS':
129128
HA1 = hash_utf8('%s:%s:%s' % (HA1, nonce, cnonce))
130129

131130
if qop is None:
132131
respdig = KD(HA1, "%s:%s" % (nonce, HA2))
133132
elif qop == 'auth' or 'auth' in qop.split(','):
133+
noncebit = "%s:%s:%s:%s:%s" % (
134+
nonce, ncvalue, cnonce, 'auth', HA2
135+
)
134136
respdig = KD(HA1, noncebit)
135137
else:
136138
# XXX handle auth-int.

pip/_vendor/requests/compat.py

-53
Original file line numberDiff line numberDiff line change
@@ -21,58 +21,6 @@
2121
#: Python 3.x?
2222
is_py3 = (_ver[0] == 3)
2323

24-
#: Python 3.0.x
25-
is_py30 = (is_py3 and _ver[1] == 0)
26-
27-
#: Python 3.1.x
28-
is_py31 = (is_py3 and _ver[1] == 1)
29-
30-
#: Python 3.2.x
31-
is_py32 = (is_py3 and _ver[1] == 2)
32-
33-
#: Python 3.3.x
34-
is_py33 = (is_py3 and _ver[1] == 3)
35-
36-
#: Python 3.4.x
37-
is_py34 = (is_py3 and _ver[1] == 4)
38-
39-
#: Python 2.7.x
40-
is_py27 = (is_py2 and _ver[1] == 7)
41-
42-
#: Python 2.6.x
43-
is_py26 = (is_py2 and _ver[1] == 6)
44-
45-
#: Python 2.5.x
46-
is_py25 = (is_py2 and _ver[1] == 5)
47-
48-
#: Python 2.4.x
49-
is_py24 = (is_py2 and _ver[1] == 4) # I'm assuming this is not by choice.
50-
51-
52-
# ---------
53-
# Platforms
54-
# ---------
55-
56-
57-
# Syntax sugar.
58-
_ver = sys.version.lower()
59-
60-
is_pypy = ('pypy' in _ver)
61-
is_jython = ('jython' in _ver)
62-
is_ironpython = ('iron' in _ver)
63-
64-
# Assume CPython, if nothing else.
65-
is_cpython = not any((is_pypy, is_jython, is_ironpython))
66-
67-
# Windows-based system.
68-
is_windows = 'win32' in str(sys.platform).lower()
69-
70-
# Standard Linux 2+ system.
71-
is_linux = ('linux' in str(sys.platform).lower())
72-
is_osx = ('darwin' in str(sys.platform).lower())
73-
is_hpux = ('hpux' in str(sys.platform).lower()) # Complete guess.
74-
is_solaris = ('solar==' in str(sys.platform).lower()) # Complete guess.
75-
7624
try:
7725
import simplejson as json
7826
except (ImportError, SyntaxError):
@@ -99,7 +47,6 @@
9947
basestring = basestring
10048
numeric_types = (int, long, float)
10149

102-
10350
elif is_py3:
10451
from urllib.parse import urlparse, urlunparse, urljoin, urlsplit, urlencode, quote, unquote, quote_plus, unquote_plus, urldefrag
10552
from urllib.request import parse_http_list, getproxies, proxy_bypass

pip/_vendor/requests/cookies.py

+49-40
Original file line numberDiff line numberDiff line change
@@ -157,26 +157,28 @@ class CookieConflictError(RuntimeError):
157157

158158

159159
class RequestsCookieJar(cookielib.CookieJar, collections.MutableMapping):
160-
"""Compatibility class; is a cookielib.CookieJar, but exposes a dict interface.
160+
"""Compatibility class; is a cookielib.CookieJar, but exposes a dict
161+
interface.
161162
162163
This is the CookieJar we create by default for requests and sessions that
163164
don't specify one, since some clients may expect response.cookies and
164165
session.cookies to support dict operations.
165166
166-
Don't use the dict interface internally; it's just for compatibility with
167-
with external client code. All `requests` code should work out of the box
168-
with externally provided instances of CookieJar, e.g., LWPCookieJar and
169-
FileCookieJar.
170-
171-
Caution: dictionary operations that are normally O(1) may be O(n).
167+
Requests does not use the dict interface internally; it's just for
168+
compatibility with external client code. All requests code should work
169+
out of the box with externally provided instances of ``CookieJar``, e.g.
170+
``LWPCookieJar`` and ``FileCookieJar``.
172171
173172
Unlike a regular CookieJar, this class is pickleable.
174-
"""
175173
174+
.. warning:: dictionary operations that are normally O(1) may be O(n).
175+
"""
176176
def get(self, name, default=None, domain=None, path=None):
177177
"""Dict-like get() that also supports optional domain and path args in
178178
order to resolve naming collisions from using one cookie jar over
179-
multiple domains. Caution: operation is O(n), not O(1)."""
179+
multiple domains.
180+
181+
.. warning:: operation is O(n), not O(1)."""
180182
try:
181183
return self._find_no_duplicates(name, domain, path)
182184
except KeyError:
@@ -199,37 +201,38 @@ def set(self, name, value, **kwargs):
199201
return c
200202

201203
def iterkeys(self):
202-
"""Dict-like iterkeys() that returns an iterator of names of cookies from the jar.
203-
See itervalues() and iteritems()."""
204+
"""Dict-like iterkeys() that returns an iterator of names of cookies
205+
from the jar. See itervalues() and iteritems()."""
204206
for cookie in iter(self):
205207
yield cookie.name
206208

207209
def keys(self):
208-
"""Dict-like keys() that returns a list of names of cookies from the jar.
209-
See values() and items()."""
210+
"""Dict-like keys() that returns a list of names of cookies from the
211+
jar. See values() and items()."""
210212
return list(self.iterkeys())
211213

212214
def itervalues(self):
213-
"""Dict-like itervalues() that returns an iterator of values of cookies from the jar.
214-
See iterkeys() and iteritems()."""
215+
"""Dict-like itervalues() that returns an iterator of values of cookies
216+
from the jar. See iterkeys() and iteritems()."""
215217
for cookie in iter(self):
216218
yield cookie.value
217219

218220
def values(self):
219-
"""Dict-like values() that returns a list of values of cookies from the jar.
220-
See keys() and items()."""
221+
"""Dict-like values() that returns a list of values of cookies from the
222+
jar. See keys() and items()."""
221223
return list(self.itervalues())
222224

223225
def iteritems(self):
224-
"""Dict-like iteritems() that returns an iterator of name-value tuples from the jar.
225-
See iterkeys() and itervalues()."""
226+
"""Dict-like iteritems() that returns an iterator of name-value tuples
227+
from the jar. See iterkeys() and itervalues()."""
226228
for cookie in iter(self):
227229
yield cookie.name, cookie.value
228230

229231
def items(self):
230-
"""Dict-like items() that returns a list of name-value tuples from the jar.
231-
See keys() and values(). Allows client-code to call "dict(RequestsCookieJar)
232-
and get a vanilla python dict of key value pairs."""
232+
"""Dict-like items() that returns a list of name-value tuples from the
233+
jar. See keys() and values(). Allows client-code to call
234+
``dict(RequestsCookieJar)`` and get a vanilla python dict of key value
235+
pairs."""
233236
return list(self.iteritems())
234237

235238
def list_domains(self):
@@ -259,8 +262,9 @@ def multiple_domains(self):
259262
return False # there is only one domain in jar
260263

261264
def get_dict(self, domain=None, path=None):
262-
"""Takes as an argument an optional domain and path and returns a plain old
263-
Python dict of name-value pairs of cookies that meet the requirements."""
265+
"""Takes as an argument an optional domain and path and returns a plain
266+
old Python dict of name-value pairs of cookies that meet the
267+
requirements."""
264268
dictionary = {}
265269
for cookie in iter(self):
266270
if (domain is None or cookie.domain == domain) and (path is None
@@ -269,21 +273,24 @@ def get_dict(self, domain=None, path=None):
269273
return dictionary
270274

271275
def __getitem__(self, name):
272-
"""Dict-like __getitem__() for compatibility with client code. Throws exception
273-
if there are more than one cookie with name. In that case, use the more
274-
explicit get() method instead. Caution: operation is O(n), not O(1)."""
276+
"""Dict-like __getitem__() for compatibility with client code. Throws
277+
exception if there are more than one cookie with name. In that case,
278+
use the more explicit get() method instead.
279+
280+
.. warning:: operation is O(n), not O(1)."""
275281

276282
return self._find_no_duplicates(name)
277283

278284
def __setitem__(self, name, value):
279-
"""Dict-like __setitem__ for compatibility with client code. Throws exception
280-
if there is already a cookie of that name in the jar. In that case, use the more
281-
explicit set() method instead."""
285+
"""Dict-like __setitem__ for compatibility with client code. Throws
286+
exception if there is already a cookie of that name in the jar. In that
287+
case, use the more explicit set() method instead."""
282288

283289
self.set(name, value)
284290

285291
def __delitem__(self, name):
286-
"""Deletes a cookie given a name. Wraps cookielib.CookieJar's remove_cookie_by_name()."""
292+
"""Deletes a cookie given a name. Wraps ``cookielib.CookieJar``'s
293+
``remove_cookie_by_name()``."""
287294
remove_cookie_by_name(self, name)
288295

289296
def set_cookie(self, cookie, *args, **kwargs):
@@ -300,10 +307,11 @@ def update(self, other):
300307
super(RequestsCookieJar, self).update(other)
301308

302309
def _find(self, name, domain=None, path=None):
303-
"""Requests uses this method internally to get cookie values. Takes as args name
304-
and optional domain and path. Returns a cookie.value. If there are conflicting cookies,
305-
_find arbitrarily chooses one. See _find_no_duplicates if you want an exception thrown
306-
if there are conflicting cookies."""
310+
"""Requests uses this method internally to get cookie values. Takes as
311+
args name and optional domain and path. Returns a cookie.value. If
312+
there are conflicting cookies, _find arbitrarily chooses one. See
313+
_find_no_duplicates if you want an exception thrown if there are
314+
conflicting cookies."""
307315
for cookie in iter(self):
308316
if cookie.name == name:
309317
if domain is None or cookie.domain == domain:
@@ -313,10 +321,11 @@ def _find(self, name, domain=None, path=None):
313321
raise KeyError('name=%r, domain=%r, path=%r' % (name, domain, path))
314322

315323
def _find_no_duplicates(self, name, domain=None, path=None):
316-
"""__get_item__ and get call _find_no_duplicates -- never used in Requests internally.
317-
Takes as args name and optional domain and path. Returns a cookie.value.
318-
Throws KeyError if cookie is not found and CookieConflictError if there are
319-
multiple cookies that match name and optionally domain and path."""
324+
"""Both ``__get_item__`` and ``get`` call this function: it's never
325+
used elsewhere in Requests. Takes as args name and optional domain and
326+
path. Returns a cookie.value. Throws KeyError if cookie is not found
327+
and CookieConflictError if there are multiple cookies that match name
328+
and optionally domain and path."""
320329
toReturn = None
321330
for cookie in iter(self):
322331
if cookie.name == name:
@@ -440,7 +449,7 @@ def merge_cookies(cookiejar, cookies):
440449
"""
441450
if not isinstance(cookiejar, cookielib.CookieJar):
442451
raise ValueError('You can only merge into CookieJar')
443-
452+
444453
if isinstance(cookies, dict):
445454
cookiejar = cookiejar_from_dict(
446455
cookies, cookiejar=cookiejar, overwrite=False)
+93-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,95 @@
1+
"""
2+
Copyright (c) Donald Stufft, pip, and individual contributors
3+
4+
Permission is hereby granted, free of charge, to any person obtaining
5+
a copy of this software and associated documentation files (the
6+
"Software"), to deal in the Software without restriction, including
7+
without limitation the rights to use, copy, modify, merge, publish,
8+
distribute, sublicense, and/or sell copies of the Software, and to
9+
permit persons to whom the Software is furnished to do so, subject to
10+
the following conditions:
11+
12+
The above copyright notice and this permission notice shall be
13+
included in all copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22+
"""
123
from __future__ import absolute_import
224

3-
from . import urllib3
25+
import sys
26+
27+
28+
class VendorAlias(object):
29+
30+
def __init__(self):
31+
self._vendor_name = __name__
32+
self._vendor_pkg = self._vendor_name + "."
33+
34+
def find_module(self, fullname, path=None):
35+
if fullname.startswith(self._vendor_pkg):
36+
return self
37+
38+
def load_module(self, name):
39+
# Ensure that this only works for the vendored name
40+
if not name.startswith(self._vendor_pkg):
41+
raise ImportError(
42+
"Cannot import %s, must be a subpackage of '%s'." % (
43+
name, self._vendor_name,
44+
)
45+
)
46+
47+
# Check to see if we already have this item in sys.modules, if we do
48+
# then simply return that.
49+
if name in sys.modules:
50+
return sys.modules[name]
51+
52+
# Check to see if we can import the vendor name
53+
try:
54+
# We do this dance here because we want to try and import this
55+
# module without hitting a recursion error because of a bunch of
56+
# VendorAlias instances on sys.meta_path
57+
real_meta_path = sys.meta_path[:]
58+
try:
59+
sys.meta_path = [
60+
m for m in sys.meta_path
61+
if not isinstance(m, VendorAlias)
62+
]
63+
__import__(name)
64+
module = sys.modules[name]
65+
finally:
66+
# Re-add any additions to sys.meta_path that were made while
67+
# during the import we just did, otherwise things like
68+
# requests.packages.urllib3.poolmanager will fail.
69+
for m in sys.meta_path:
70+
if m not in real_meta_path:
71+
real_meta_path.append(m)
72+
73+
# Restore sys.meta_path with any new items.
74+
sys.meta_path = real_meta_path
75+
except ImportError:
76+
# We can't import the vendor name, so we'll try to import the
77+
# "real" name.
78+
real_name = name[len(self._vendor_pkg):]
79+
try:
80+
__import__(real_name)
81+
module = sys.modules[real_name]
82+
except ImportError:
83+
raise ImportError("No module named '%s'" % (name,))
84+
85+
# If we've gotten here we've found the module we're looking for, either
86+
# as part of our vendored package, or as the real name, so we'll add
87+
# it to sys.modules as the vendored name so that we don't have to do
88+
# the lookup again.
89+
sys.modules[name] = module
90+
91+
# Finally, return the loaded module
92+
return module
93+
94+
95+
sys.meta_path.append(VendorAlias())

pip/_vendor/requests/packages/urllib3/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def add_stderr_logger(level=logging.DEBUG):
5555
del NullHandler
5656

5757

58-
# Set security warning to only go off once by default.
58+
# Set security warning to always go off by default.
5959
import warnings
6060
warnings.simplefilter('always', exceptions.SecurityWarning)
6161

0 commit comments

Comments
 (0)