urllib3 update
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Kenneth Reitz · committed by Kenneth Reitz · parent fe68826 · Browse files · 6 files·+43 added−26 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
6 files+43 added−26 removed
- other:+43 added−26 removed
Provenance
- Commit
125619c- Tree
eb7e99c- Author
Kenneth Reitz <me@kennethreitz.com>- Committer
Kenneth Reitz <me@kennethreitz.com>- Parent
fe68826
6 files changed+43 added−26 removed
modified:requests/packages/urllib3/contrib/ntlmpool.py+1 added-1 removed
11 unmodified lines12 13 try:14 from http.client import HTTPSConnection15 except ImportError:16- from http.client import HTTPSConnection16+ from httplib import HTTPSConnection17 from logging import getLogger18 from ntlm import ntlm19 20 from urllib3 import HTTPSConnectionPool100 unmodified linesmodified:requests/packages/urllib3/packages/__init__.py+1 added-1 removed
1+from __future__ import absolute_import2 2-3 from . import ssl_match_hostname4 modified:requests/packages/urllib3/packages/six.py+15 added-15 removed
37 unmodified lines38 binary_type = bytes39 40 MAXSIZE = sys.maxsize41 else:42- string_types = str,43- integer_types = (int, int)44- class_types = (type, type)45- text_type = str42+ string_types = basestring,43+ integer_types = (int, long)44+ class_types = (type, types.ClassType)45+ text_type = unicode46 binary_type = str47 48 # It's possible to have sizeof(long) != sizeof(Py_ssize_t).49 class X(object):179 unmodified lines229 def callable(obj):230 return any("__call__" in klass.__dict__ for klass in type(obj).__mro__)231 else:232 def get_unbound_function(unbound):233- return unbound.__func__233+ return unbound.im_func234 235 236 def advance_iterator(it):237- return next(it)237+ return it.next()238 239 callable = callable240 _add_doc(get_unbound_function,241 """Get the function out of a possibly unbound function""")35 unmodified lines277 else:278 def b(s):279 return s280 def u(s):281- return str(s, "unicode_escape")281+ return unicode(s, "unicode_escape")282 int2byte = chr283- import io284- StringIO = BytesIO = io.StringIO283+ import StringIO284+ StringIO = BytesIO = StringIO.StringIO285 _add_doc(b, """Byte literal""")286 _add_doc(u, """Text literal""")287 288 35 unmodified lines324 fp = kwargs.pop("file", sys.stdout)325 if fp is None:326 return327 def write(data):328- if not isinstance(data, str):328+ if not isinstance(data, basestring):329 data = str(data)330 fp.write(data)331 want_unicode = False332 sep = kwargs.pop("sep", None)333 if sep is not None:334- if isinstance(sep, str):334+ if isinstance(sep, unicode):335 want_unicode = True336 elif not isinstance(sep, str):337 raise TypeError("sep must be None or a string")338 end = kwargs.pop("end", None)339 if end is not None:340- if isinstance(end, str):340+ if isinstance(end, unicode):341 want_unicode = True342 elif not isinstance(end, str):343 raise TypeError("end must be None or a string")344 if kwargs:345 raise TypeError("invalid keyword arguments to print()")346 if not want_unicode:347 for arg in args:348- if isinstance(arg, str):348+ if isinstance(arg, unicode):349 want_unicode = True350 break351 if want_unicode:352- newline = str("\n")353- space = str(" ")352+ newline = unicode("\n")353+ space = unicode(" ")354 else:355 newline = "\n"356 space = " "357 if sep is None:15 unmodified linesmodified:requests/packages/urllib3/connectionpool.py+18 added-6 removed
5 unmodified lines6 7 import logging8 import socket9 10-from select import poll, POLLIN10+from httplib import (HTTPConnection, HTTPSConnection, HTTPException,11+ HTTP_PORT, HTTPS_PORT)12+13+from Queue import Queue, Empty, Full14 from socket import error as SocketError, timeout as SocketTimeout15 16+try:17+ from select import poll, POLLIN18+except ImportError: # Doesn't exist on OSX and other platforms19+ from select import select20+ poll = False21 22 try: # Python 323 from http.client import HTTPConnection, HTTPSConnection, HTTPException24 from http.client import HTTP_PORT, HTTPS_PORT25 except ImportError:18- from http.client import HTTPConnection, HTTPSConnection, HTTPException19- from http.client import HTTP_PORT, HTTPS_PORT26+ from httplib import HTTPConnection, HTTPSConnection, HTTPException27+ from httplib import HTTP_PORT, HTTPS_PORT28 29 try: # Python 330 from queue import Queue, Empty, Full31 except ImportError:24- from queue import Queue, Empty, Full32+ from Queue import Queue, Empty, Full33 34 try: # Compiled with SSL?35 import ssl36 BaseSSLError = ssl.SSLError1 unmodified line38 ssl = None39 BaseSSLError = None40 41 42+from .packages.ssl_match_hostname import match_hostname, CertificateError43 from .request import RequestMethods44 from .response import HTTPResponse45 from .exceptions import (SSLError,46 MaxRetryError,121 unmodified lines168 self.block = block169 self.headers = headers or {}170 171 # Fill the queue up so that doing get() on it will block properly163- for _ in range(maxsize):172+ for _ in xrange(maxsize):173 self.pool.put(None)174 175 # These are mostly for testing and debugging purposes.176 self.num_connections = 0418 unmodified lines595 596 :param conn:597 ``HTTPConnection`` object.598 """590- # poll-based replacement to select([conn.sock], [], [], 0.0)[0]:599+ if not poll:600+ return select([conn.sock], [], [], 0.0)[0]601+602+ # This version is better on platforms that support it.603 p = poll()604 p.register(conn.sock, POLLIN)605 for (fno, ev) in p.poll(0.0):606 if fno == conn.sock.fileno():2 unmodified linesmodified:requests/packages/urllib3/request.py+1 added-1 removed
5 unmodified lines6 7 try:8 from urllib.parse import urlencode9 except ImportError:10- from urllib.parse import urlencode10+ from urllib import urlencode11 12 from .filepost import encode_multipart_formdata13 14 133 unmodified linesmodified:requests/packages/urllib3/response.py+7 added-2 removed
8 unmodified lines9 import zlib10 11 from io import BytesIO12 13-13 from .exceptions import HTTPError14 15 16+try:17+ basestring = basestring18+except NameError: # Python 319+ basestring = (str, bytes)20+21+22 log = logging.getLogger(__name__)23 24 25 def decode_gzip(data):45 unmodified lines71 self.reason = reason72 self.strict = strict73 74 self._decode_content = decode_content70- self._body = body if body and isinstance(body, str) else None75+ self._body = body if body and isinstance(body, basestring) else None76 self._fp = None77 self._original_response = original_response78 79 self._pool = pool117 unmodified lines