[Bf-blender-cvs] SVN commit: /data/svn/repos/bf-blender [61658] trunk/lib/python/site-packages/requests: Requests 2.10

Martijn Berger martijn.berger at gmail.com
Sun May 8 13:58:07 CEST 2016


Revision: 61658
          https://developer.blender.org/rBL61658
Author:   juicyfruit
Date:     2016-05-08 11:58:06 +0000 (Sun, 08 May 2016)
Log Message:
-----------
Requests 2.10

Modified Paths:
--------------
    trunk/lib/python/site-packages/requests/__init__.py
    trunk/lib/python/site-packages/requests/adapters.py
    trunk/lib/python/site-packages/requests/api.py
    trunk/lib/python/site-packages/requests/auth.py
    trunk/lib/python/site-packages/requests/cacert.pem
    trunk/lib/python/site-packages/requests/compat.py
    trunk/lib/python/site-packages/requests/cookies.py
    trunk/lib/python/site-packages/requests/exceptions.py
    trunk/lib/python/site-packages/requests/hooks.py
    trunk/lib/python/site-packages/requests/models.py
    trunk/lib/python/site-packages/requests/packages/__init__.py
    trunk/lib/python/site-packages/requests/packages/urllib3/__init__.py
    trunk/lib/python/site-packages/requests/packages/urllib3/_collections.py
    trunk/lib/python/site-packages/requests/packages/urllib3/connection.py
    trunk/lib/python/site-packages/requests/packages/urllib3/connectionpool.py
    trunk/lib/python/site-packages/requests/packages/urllib3/contrib/ntlmpool.py
    trunk/lib/python/site-packages/requests/packages/urllib3/contrib/pyopenssl.py
    trunk/lib/python/site-packages/requests/packages/urllib3/exceptions.py
    trunk/lib/python/site-packages/requests/packages/urllib3/fields.py
    trunk/lib/python/site-packages/requests/packages/urllib3/filepost.py
    trunk/lib/python/site-packages/requests/packages/urllib3/packages/__init__.py
    trunk/lib/python/site-packages/requests/packages/urllib3/poolmanager.py
    trunk/lib/python/site-packages/requests/packages/urllib3/request.py
    trunk/lib/python/site-packages/requests/packages/urllib3/response.py
    trunk/lib/python/site-packages/requests/packages/urllib3/util/__init__.py
    trunk/lib/python/site-packages/requests/packages/urllib3/util/connection.py
    trunk/lib/python/site-packages/requests/packages/urllib3/util/request.py
    trunk/lib/python/site-packages/requests/packages/urllib3/util/response.py
    trunk/lib/python/site-packages/requests/packages/urllib3/util/retry.py
    trunk/lib/python/site-packages/requests/packages/urllib3/util/ssl_.py
    trunk/lib/python/site-packages/requests/packages/urllib3/util/timeout.py
    trunk/lib/python/site-packages/requests/packages/urllib3/util/url.py
    trunk/lib/python/site-packages/requests/sessions.py
    trunk/lib/python/site-packages/requests/status_codes.py
    trunk/lib/python/site-packages/requests/structures.py
    trunk/lib/python/site-packages/requests/utils.py

Added Paths:
-----------
    trunk/lib/python/site-packages/requests/packages/urllib3/contrib/appengine.py
    trunk/lib/python/site-packages/requests/packages/urllib3/contrib/socks.py

Modified: trunk/lib/python/site-packages/requests/__init__.py
===================================================================
--- trunk/lib/python/site-packages/requests/__init__.py	2016-05-04 12:46:09 UTC (rev 61657)
+++ trunk/lib/python/site-packages/requests/__init__.py	2016-05-08 11:58:06 UTC (rev 61658)
@@ -6,7 +6,7 @@
 #          /
 
 """
-requests HTTP library
+Requests HTTP library
 ~~~~~~~~~~~~~~~~~~~~~
 
 Requests is an HTTP library, written in Python, for human beings. Basic GET
@@ -36,17 +36,17 @@
 The other HTTP methods are supported - see `requests.api`. Full documentation
 is at <http://python-requests.org>.
 
-:copyright: (c) 2014 by Kenneth Reitz.
+:copyright: (c) 2016 by Kenneth Reitz.
 :license: Apache 2.0, see LICENSE for more details.
 
 """
 
 __title__ = 'requests'
-__version__ = '2.5.0'
-__build__ = 0x020500
+__version__ = '2.10.0'
+__build__ = 0x021000
 __author__ = 'Kenneth Reitz'
 __license__ = 'Apache 2.0'
-__copyright__ = 'Copyright 2014 Kenneth Reitz'
+__copyright__ = 'Copyright 2016 Kenneth Reitz'
 
 # Attempt to enable urllib3's SNI support, if possible
 try:
@@ -55,6 +55,12 @@
 except ImportError:
     pass
 
+import warnings
+
+# urllib3's DependencyWarnings should be silenced.
+from .packages.urllib3.exceptions import DependencyWarning
+warnings.simplefilter('ignore', DependencyWarning)
+
 from . import utils
 from .models import Request, Response, PreparedRequest
 from .api import request, get, head, post, patch, put, delete, options
@@ -62,7 +68,8 @@
 from .status_codes import codes
 from .exceptions import (
     RequestException, Timeout, URLRequired,
-    TooManyRedirects, HTTPError, ConnectionError
+    TooManyRedirects, HTTPError, ConnectionError,
+    FileModeWarning, ConnectTimeout, ReadTimeout
 )
 
 # Set default logging handler to avoid "No handler found" warnings.
@@ -75,3 +82,8 @@
             pass
 
 logging.getLogger(__name__).addHandler(NullHandler())
+
+import warnings
+
+# FileModeWarnings go off per the default.
+warnings.simplefilter('default', FileModeWarning, append=True)

Modified: trunk/lib/python/site-packages/requests/adapters.py
===================================================================
--- trunk/lib/python/site-packages/requests/adapters.py	2016-05-04 12:46:09 UTC (rev 61657)
+++ trunk/lib/python/site-packages/requests/adapters.py	2016-05-08 11:58:06 UTC (rev 61658)
@@ -8,20 +8,24 @@
 and maintain connections.
 """
 
+import os.path
 import socket
 
 from .models import Response
-from .packages.urllib3 import Retry
 from .packages.urllib3.poolmanager import PoolManager, proxy_from_url
 from .packages.urllib3.response import HTTPResponse
 from .packages.urllib3.util import Timeout as TimeoutSauce
+from .packages.urllib3.util.retry import Retry
 from .compat import urlparse, basestring
 from .utils import (DEFAULT_CA_BUNDLE_PATH, get_encoding_from_headers,
-                    prepend_scheme_if_needed, get_auth_from_url, urldefragauth)
+                    prepend_scheme_if_needed, get_auth_from_url, urldefragauth,
+                    select_proxy, to_native_string)
 from .structures import CaseInsensitiveDict
+from .packages.urllib3.exceptions import ClosedPoolError
 from .packages.urllib3.exceptions import ConnectTimeoutError
 from .packages.urllib3.exceptions import HTTPError as _HTTPError
 from .packages.urllib3.exceptions import MaxRetryError
+from .packages.urllib3.exceptions import NewConnectionError
 from .packages.urllib3.exceptions import ProxyError as _ProxyError
 from .packages.urllib3.exceptions import ProtocolError
 from .packages.urllib3.exceptions import ReadTimeoutError
@@ -29,12 +33,19 @@
 from .packages.urllib3.exceptions import ResponseError
 from .cookies import extract_cookies_to_jar
 from .exceptions import (ConnectionError, ConnectTimeout, ReadTimeout, SSLError,
-                         ProxyError, RetryError)
+                         ProxyError, RetryError, InvalidSchema)
 from .auth import _basic_auth_str
 
+try:
+    from .packages.urllib3.contrib.socks import SOCKSProxyManager
+except ImportError:
+    def SOCKSProxyManager(*args, **kwargs):
+        raise InvalidSchema("Missing dependencies for SOCKS support.")
+
 DEFAULT_POOLBLOCK = False
 DEFAULT_POOLSIZE = 10
 DEFAULT_RETRIES = 0
+DEFAULT_POOL_TIMEOUT = None
 
 
 class BaseAdapter(object):
@@ -60,7 +71,7 @@
 
     :param pool_connections: The number of urllib3 connection pools to cache.
     :param pool_maxsize: The maximum number of connections to save in the pool.
-    :param int max_retries: The maximum number of retries each connection
+    :param max_retries: The maximum number of retries each connection
         should attempt. Note, this applies only to failed DNS lookups, socket
         connections and connection timeouts, never to requests where data has
         made it to the server. By default, Requests does not retry failed
@@ -103,7 +114,7 @@
 
     def __setstate__(self, state):
         # Can't handle by adding 'proxy_manager' to self.__attrs__ because
-        # because self.poolmanager uses a lambda function, which isn't pickleable.
+        # self.poolmanager uses a lambda function, which isn't pickleable.
         self.proxy_manager = {}
         self.config = {}
 
@@ -144,9 +155,22 @@
         :param proxy_kwargs: Extra keyword arguments used to configure the Proxy Manager.
         :returns: ProxyManager
         """
-        if not proxy in self.proxy_manager:
+        if proxy in self.proxy_manager:
+            manager = self.proxy_manager[proxy]
+        elif proxy.lower().startswith('socks'):
+            username, password = get_auth_from_url(proxy)
+            manager = self.proxy_manager[proxy] = SOCKSProxyManager(
+                proxy,
+                username=username,
+                password=password,
+                num_pools=self._pool_connections,
+                maxsize=self._pool_maxsize,
+                block=self._pool_block,
+                **proxy_kwargs
+            )
+        else:
             proxy_headers = self.proxy_headers(proxy)
-            self.proxy_manager[proxy] = proxy_from_url(
+            manager = self.proxy_manager[proxy] = proxy_from_url(
                 proxy,
                 proxy_headers=proxy_headers,
                 num_pools=self._pool_connections,
@@ -154,7 +178,7 @@
                 block=self._pool_block,
                 **proxy_kwargs)
 
-        return self.proxy_manager[proxy]
+        return manager
 
     def cert_verify(self, conn, url, verify, cert):
         """Verify a SSL certificate. This method should not be called from user
@@ -181,10 +205,15 @@
                 raise Exception("Could not find a suitable SSL CA certificate bundle.")
 
             conn.cert_reqs = 'CERT_REQUIRED'
-            conn.ca_certs = cert_loc
+
+            if not os.path.isdir(cert_loc):
+                conn.ca_certs = cert_loc
+            else:
+                conn.ca_cert_dir = cert_loc
         else:
             conn.cert_reqs = 'CERT_NONE'
             conn.ca_certs = None
+            conn.ca_cert_dir = None
 
         if cert:
             if not isinstance(cert, basestring):
@@ -237,8 +266,7 @@
         :param url: The URL to connect to.
         :param proxies: (optional) A Requests-style dictionary of proxies used on this request.
         """
-        proxies = proxies or {}
-        proxy = proxies.get(urlparse(url.lower()).scheme)
+        proxy = select_proxy(url, proxies)
 
         if proxy:
             proxy = prepend_scheme_if_needed(proxy, 'http')
@@ -255,10 +283,12 @@
     def close(self):
         """Disposes of any internal state.
 
-        Currently, this just closes the PoolManager, which closes pooled
-        connections.
+        Currently, this closes the PoolManager and any active ProxyManager,
+        which closes any pooled connections.
         """
         self.poolmanager.clear()
+        for proxy in self.proxy_manager.values():
+            proxy.clear()
 
     def request_url(self, request, proxies):
         """Obtain the url to use when making the final request.
@@ -271,16 +301,20 @@
         :class:`HTTPAdapter <requests.adapters.HTTPAdapter>`.
 
         :param request: The :class:`PreparedRequest <PreparedRequest>` being sent.
-        :param proxies: A dictionary of schemes to proxy URLs.
+        :param proxies: A dictionary of schemes or schemes and hosts to proxy URLs.
         """
-        proxies = proxies or {}
+        proxy = select_proxy(request.url, proxies)
         scheme = urlparse(request.url).scheme
-        proxy = proxies.get(scheme)
 
-        if proxy and scheme != 'https':
+        is_proxied_http_request = (proxy and scheme != 'https')
+        using_socks_proxy = False
+        if proxy:
+            proxy_scheme = urlparse(proxy).scheme.lower()
+            using_socks_proxy = proxy_scheme.startswith('socks')
+
+        url = request.path_url
+        if is_proxied_http_request and not using_socks_proxy:
             url = urldefragauth(request.url)
-        else:
-            url = request.path_url
 
         return url
 
@@ -309,7 +343,6 @@
         :class:`HTTPAdapter <requests.adapters.HTTPAdapter>`.
 
         :param proxies: The url of the proxy being used for this request.
-        :param kwargs: Optional additional keyword arguments.
         """
         headers = {}
         username, password = get_auth_from_url(proxy)
@@ -326,8 +359,8 @@
         :param request: The :class:`PreparedRequest <PreparedRequest>` being sent.
         :param stream: (optional) Whether to stream the request content.
         :param timeout: (optional) How long to wait for the server to send
-            data before giving up, as a float, or a (`connect timeout, read
-            timeout <user/advanced.html#timeouts>`_) tuple.
+            data before giving up, as a float, or a :ref:`(connect timeout,
+            read timeout) <timeouts>` tuple.
         :type timeout: float or tuple
         :param verify: (optional) Whether to verify SSL certificates.
         :param cert: (optional) Any user-provided SSL certificate to be trusted.
@@ -375,7 +408,7 @@
                 if hasattr(conn, 'proxy_pool'):
                     conn = conn.proxy_pool
 
-                low_conn = conn._get_conn(timeout=timeout)
+                low_conn = conn._get_conn(timeout=DEFAULT_POOL_TIMEOUT)
 
                 try:
                     low_conn.putrequest(request.method,
@@ -394,7 +427,15 @@

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list