prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  SSLAdapter init_poolmanager error because request.packages.urllib3.__version__ invalid
  In ssladapter.py, 
  
  ``` python
  try:
      import requests.packages.urllib3 as urllib3
  except ImportError:
      import urllib3
  ...
  
          if urllib3 and urllib_ver == 'dev' and \
             StrictVersion(urllib_ver) > StrictVersion('1.5'):
              kwargs['ssl_version'] = self.ssl_version
  
          self.poolmanager = PoolManager(**kwargs)
  ```
  
  `requests.packages.urllib3` will be imported, and the `requests.packages.urllib3.__version__` is 'dev' at present, and the `StrictVersion(urllib_ver)` will raise a ValueError: "invalid version number 'dev'"
  
  
  </issue>
  <code>
  [start of docker/tls.py]
  1 import os
  2 
  3 from . import errors
  4 from .ssladapter import ssladapter
  5 
  6 
  7 class TLSConfig(object):
  8     cert = None
  9     verify = None
  10     ssl_version = None
  11 
  12     def __init__(self, client_cert=None, ca_cert=None, verify=None,
  13                  ssl_version=None):
  14         # Argument compatibility/mapping with
  15         # http://docs.docker.com/examples/https/
  16         # This diverges from the Docker CLI in that users can specify 'tls'
  17         # here, but also disable any public/default CA pool verification by
  18         # leaving tls_verify=False
  19 
  20         # urllib3 sets a default ssl_version if ssl_version is None
  21         # http://tinyurl.com/kxga8hb
  22         self.ssl_version = ssl_version
  23 
  24         # "tls" and "tls_verify" must have both or neither cert/key files
  25         # In either case, Alert the user when both are expected, but any are
  26         # missing.
  27 
  28         if client_cert:
  29             try:
  30                 tls_cert, tls_key = client_cert
  31             except ValueError:
  32                 raise errors.TLSParameterError(
  33                     'client_config must be a tuple of'
  34                     ' (client certificate, key file)'
  35                 )
  36 
  37             if not (tls_cert and tls_key) or (not os.path.isfile(tls_cert) or
  38                not os.path.isfile(tls_key)):
  39                 raise errors.TLSParameterError(
  40                     'Path to a certificate and key files must be provided'
  41                     ' through the client_config param'
  42                 )
  43             self.cert = (tls_cert, tls_key)
  44 
  45         # Either set verify to True (public/default CA checks) or to the
  46         # path of a CA Cert file.
  47         if verify is not None:
  48             if not ca_cert:
  49                 self.verify = verify
  50             elif os.path.isfile(ca_cert):
  51                 if not verify:
  52                     raise errors.TLSParameterError(
  53                         'verify can not be False when a CA cert is'
  54                         ' provided.'
  55                     )
  56                 self.verify = ca_cert
  57             else:
  58                 raise errors.TLSParameterError(
  59                     'Invalid CA certificate provided for `tls_ca_cert`.'
  60                 )
  61 
  62     def configure_client(self, client):
  63         client.ssl_version = self.ssl_version
  64         if self.verify is not None:
  65             client.verify = self.verify
  66         if self.cert:
  67             client.cert = self.cert
  68         client.mount('https://', ssladapter.SSLAdapter(self.ssl_version))
  69
  [end of docker/tls.py]
  [start of docker/ssladapter/ssladapter.py]
  1 """ Resolves OpenSSL issues in some servers:
  2       https://lukasa.co.uk/2013/01/Choosing_SSL_Version_In_Requests/
  3       https://github.com/kennethreitz/requests/pull/799
  4 """
  5 from distutils.version import StrictVersion
  6 from requests.adapters import HTTPAdapter
  7 try:
  8     import requests.packages.urllib3 as urllib3
  9 except ImportError:
  10     import urllib3
  11 
  12 
  13 PoolManager = urllib3.poolmanager.PoolManager
  14 
  15 
  16 class SSLAdapter(HTTPAdapter):
  17     '''An HTTPS Transport Adapter that uses an arbitrary SSL version.'''
  18     def __init__(self, ssl_version=None, **kwargs):
  19         self.ssl_version = ssl_version
  20         super(SSLAdapter, self).__init__(**kwargs)
  21 
  22     def init_poolmanager(self, connections, maxsize, block=False):
  23         urllib_ver = urllib3.__version__.split('-')[0]
  24         kwargs = {
  25             'num_pools': connections,
  26             'maxsize': maxsize,
  27             'block': block
  28         }
  29         if urllib3 and urllib_ver == 'dev' and \
  30            StrictVersion(urllib_ver) > StrictVersion('1.5'):
  31             kwargs['ssl_version'] = self.ssl_version
  32 
  33         self.poolmanager = PoolManager(**kwargs)
  34
  [end of docker/ssladapter/ssladapter.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/docker/ssladapter/ssladapter.py b/docker/ssladapter/ssladapter.py
  --- a/docker/ssladapter/ssladapter.py
  +++ b/docker/ssladapter/ssladapter.py
  @@ -15,19 +15,27 @@
   
   class SSLAdapter(HTTPAdapter):
       '''An HTTPS Transport Adapter that uses an arbitrary SSL version.'''
  -    def __init__(self, ssl_version=None, **kwargs):
  +    def __init__(self, ssl_version=None, assert_hostname=None, **kwargs):
           self.ssl_version = ssl_version
  +        self.assert_hostname = assert_hostname
           super(SSLAdapter, self).__init__(**kwargs)
   
       def init_poolmanager(self, connections, maxsize, block=False):
  -        urllib_ver = urllib3.__version__.split('-')[0]
           kwargs = {
               'num_pools': connections,
               'maxsize': maxsize,
  -            'block': block
  +            'block': block,
  +            'assert_hostname': self.assert_hostname,
           }
  -        if urllib3 and urllib_ver == 'dev' and \
  -           StrictVersion(urllib_ver) > StrictVersion('1.5'):
  +        if self.can_override_ssl_version():
               kwargs['ssl_version'] = self.ssl_version
   
           self.poolmanager = PoolManager(**kwargs)
  +
  +    def can_override_ssl_version(self):
  +        urllib_ver = urllib3.__version__.split('-')[0]
  +        if urllib_ver is None:
  +            return False
  +        if urllib_ver == 'dev':
  +            return True
  +        return StrictVersion(urllib_ver) > StrictVersion('1.5')
  diff --git a/docker/tls.py b/docker/tls.py
  --- a/docker/tls.py
  +++ b/docker/tls.py
  @@ -10,7 +10,7 @@
       ssl_version = None
   
       def __init__(self, client_cert=None, ca_cert=None, verify=None,
  -                 ssl_version=None):
  +                 ssl_version=None, assert_hostname=None):
           # Argument compatibility/mapping with
           # http://docs.docker.com/examples/https/
           # This diverges from the Docker CLI in that users can specify 'tls'
  @@ -20,6 +20,7 @@
           # urllib3 sets a default ssl_version if ssl_version is None
           # http://tinyurl.com/kxga8hb
           self.ssl_version = ssl_version
  +        self.assert_hostname = assert_hostname
   
           # "tls" and "tls_verify" must have both or neither cert/key files
           # In either case, Alert the user when both are expected, but any are
  @@ -65,4 +66,7 @@
               client.verify = self.verify
           if self.cert:
               client.cert = self.cert
  -        client.mount('https://', ssladapter.SSLAdapter(self.ssl_version))
  +        client.mount('https://', ssladapter.SSLAdapter(
  +            ssl_version=self.ssl_version,
  +            assert_hostname=self.assert_hostname,
  +        ))
  
verification_info: {"golden_diff": "diff --git a/docker/ssladapter/ssladapter.py b/docker/ssladapter/ssladapter.py\n--- a/docker/ssladapter/ssladapter.py\n+++ b/docker/ssladapter/ssladapter.py\n@@ -15,19 +15,27 @@\n \n class SSLAdapter(HTTPAdapter):\n     '''An HTTPS Transport Adapter that uses an arbitrary SSL version.'''\n-    def __init__(self, ssl_version=None, **kwargs):\n+    def __init__(self, ssl_version=None, assert_hostname=None, **kwargs):\n         self.ssl_version = ssl_version\n+        self.assert_hostname = assert_hostname\n         super(SSLAdapter, self).__init__(**kwargs)\n \n     def init_poolmanager(self, connections, maxsize, block=False):\n-        urllib_ver = urllib3.__version__.split('-')[0]\n         kwargs = {\n             'num_pools': connections,\n             'maxsize': maxsize,\n-            'block': block\n+            'block': block,\n+            'assert_hostname': self.assert_hostname,\n         }\n-        if urllib3 and urllib_ver == 'dev' and \\\n-           StrictVersion(urllib_ver) > StrictVersion('1.5'):\n+        if self.can_override_ssl_version():\n             kwargs['ssl_version'] = self.ssl_version\n \n         self.poolmanager = PoolManager(**kwargs)\n+\n+    def can_override_ssl_version(self):\n+        urllib_ver = urllib3.__version__.split('-')[0]\n+        if urllib_ver is None:\n+            return False\n+        if urllib_ver == 'dev':\n+            return True\n+        return StrictVersion(urllib_ver) > StrictVersion('1.5')\ndiff --git a/docker/tls.py b/docker/tls.py\n--- a/docker/tls.py\n+++ b/docker/tls.py\n@@ -10,7 +10,7 @@\n     ssl_version = None\n \n     def __init__(self, client_cert=None, ca_cert=None, verify=None,\n-                 ssl_version=None):\n+                 ssl_version=None, assert_hostname=None):\n         # Argument compatibility/mapping with\n         # http://docs.docker.com/examples/https/\n         # This diverges from the Docker CLI in that users can specify 'tls'\n@@ -20,6 +20,7 @@\n         # urllib3 sets a default ssl_version if ssl_version is None\n         # http://tinyurl.com/kxga8hb\n         self.ssl_version = ssl_version\n+        self.assert_hostname = assert_hostname\n \n         # \"tls\" and \"tls_verify\" must have both or neither cert/key files\n         # In either case, Alert the user when both are expected, but any are\n@@ -65,4 +66,7 @@\n             client.verify = self.verify\n         if self.cert:\n             client.cert = self.cert\n-        client.mount('https://', ssladapter.SSLAdapter(self.ssl_version))\n+        client.mount('https://', ssladapter.SSLAdapter(\n+            ssl_version=self.ssl_version,\n+            assert_hostname=self.assert_hostname,\n+        ))\n", "issue": "SSLAdapter init_poolmanager error because request.packages.urllib3.__version__ invalid\nIn ssladapter.py, \n\n``` python\ntry:\n    import requests.packages.urllib3 as urllib3\nexcept ImportError:\n    import urllib3\n...\n\n        if urllib3 and urllib_ver == 'dev' and \\\n           StrictVersion(urllib_ver) > StrictVersion('1.5'):\n            kwargs['ssl_version'] = self.ssl_version\n\n        self.poolmanager = PoolManager(**kwargs)\n```\n\n`requests.packages.urllib3` will be imported, and the `requests.packages.urllib3.__version__` is 'dev' at present, and the `StrictVersion(urllib_ver)` will raise a ValueError: \"invalid version number 'dev'\"\n\n", "before_files": [{"content": "import os\n\nfrom . import errors\nfrom .ssladapter import ssladapter\n\n\nclass TLSConfig(object):\n    cert = None\n    verify = None\n    ssl_version = None\n\n    def __init__(self, client_cert=None, ca_cert=None, verify=None,\n                 ssl_version=None):\n        # Argument compatibility/mapping with\n        # http://docs.docker.com/examples/https/\n        # This diverges from the Docker CLI in that users can specify 'tls'\n        # here, but also disable any public/default CA pool verification by\n        # leaving tls_verify=False\n\n        # urllib3 sets a default ssl_version if ssl_version is None\n        # http://tinyurl.com/kxga8hb\n        self.ssl_version = ssl_version\n\n        # \"tls\" and \"tls_verify\" must have both or neither cert/key files\n        # In either case, Alert the user when both are expected, but any are\n        # missing.\n\n        if client_cert:\n            try:\n                tls_cert, tls_key = client_cert\n            except ValueError:\n                raise errors.TLSParameterError(\n                    'client_config must be a tuple of'\n                    ' (client certificate, key file)'\n                )\n\n            if not (tls_cert and tls_key) or (not os.path.isfile(tls_cert) or\n               not os.path.isfile(tls_key)):\n                raise errors.TLSParameterError(\n                    'Path to a certificate and key files must be provided'\n                    ' through the client_config param'\n                )\n            self.cert = (tls_cert, tls_key)\n\n        # Either set verify to True (public/default CA checks) or to the\n        # path of a CA Cert file.\n        if verify is not None:\n            if not ca_cert:\n                self.verify = verify\n            elif os.path.isfile(ca_cert):\n                if not verify:\n                    raise errors.TLSParameterError(\n                        'verify can not be False when a CA cert is'\n                        ' provided.'\n                    )\n                self.verify = ca_cert\n            else:\n                raise errors.TLSParameterError(\n                    'Invalid CA certificate provided for `tls_ca_cert`.'\n                )\n\n    def configure_client(self, client):\n        client.ssl_version = self.ssl_version\n        if self.verify is not None:\n            client.verify = self.verify\n        if self.cert:\n            client.cert = self.cert\n        client.mount('https://', ssladapter.SSLAdapter(self.ssl_version))\n", "path": "docker/tls.py"}, {"content": "\"\"\" Resolves OpenSSL issues in some servers:\n      https://lukasa.co.uk/2013/01/Choosing_SSL_Version_In_Requests/\n      https://github.com/kennethreitz/requests/pull/799\n\"\"\"\nfrom distutils.version import StrictVersion\nfrom requests.adapters import HTTPAdapter\ntry:\n    import requests.packages.urllib3 as urllib3\nexcept ImportError:\n    import urllib3\n\n\nPoolManager = urllib3.poolmanager.PoolManager\n\n\nclass SSLAdapter(HTTPAdapter):\n    '''An HTTPS Transport Adapter that uses an arbitrary SSL version.'''\n    def __init__(self, ssl_version=None, **kwargs):\n        self.ssl_version = ssl_version\n        super(SSLAdapter, self).__init__(**kwargs)\n\n    def init_poolmanager(self, connections, maxsize, block=False):\n        urllib_ver = urllib3.__version__.split('-')[0]\n        kwargs = {\n            'num_pools': connections,\n            'maxsize': maxsize,\n            'block': block\n        }\n        if urllib3 and urllib_ver == 'dev' and \\\n           StrictVersion(urllib_ver) > StrictVersion('1.5'):\n            kwargs['ssl_version'] = self.ssl_version\n\n        self.poolmanager = PoolManager(**kwargs)\n", "path": "docker/ssladapter/ssladapter.py"}]}