prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  empty WARNING message in scrapy.core.downloader.tls (1.1.0rc4/master)
  Sometimes I'm getting empty warnings now, on 1.1.0rc4 and master branch.
  (at least on rc3 as well)
  
  ```
  2016-05-07 00:33:46 [scrapy.core.downloader.tls] WARNING: 
  2016-05-07 00:33:47 [scrapy.core.downloader.tls] WARNING: 
  2016-05-07 00:33:48 [scrapy.core.downloader.tls] WARNING: 
  ```
  
  It happens in a broad linkcheck crawl; so I couldn't pinpoint what URLs might be responsible for that, at this time. The only other observation so far is, that it doesn't happen on a cache-replayed run (which might be obvious, as there is no TLS there).
  
  
  </issue>
  <code>
  [start of scrapy/core/downloader/tls.py]
  1 import logging
  2 from OpenSSL import SSL
  3 
  4 
  5 logger = logging.getLogger(__name__)
  6 
  7 METHOD_SSLv3 = 'SSLv3'
  8 METHOD_TLS = 'TLS'
  9 METHOD_TLSv10 = 'TLSv1.0'
  10 METHOD_TLSv11 = 'TLSv1.1'
  11 METHOD_TLSv12 = 'TLSv1.2'
  12 
  13 openssl_methods = {
  14     METHOD_TLS:    SSL.SSLv23_METHOD,                   # protocol negotiation (recommended)
  15     METHOD_SSLv3:  SSL.SSLv3_METHOD,                    # SSL 3 (NOT recommended)
  16     METHOD_TLSv10: SSL.TLSv1_METHOD,                    # TLS 1.0 only
  17     METHOD_TLSv11: getattr(SSL, 'TLSv1_1_METHOD', 5),   # TLS 1.1 only
  18     METHOD_TLSv12: getattr(SSL, 'TLSv1_2_METHOD', 6),   # TLS 1.2 only
  19 }
  20 
  21 # ClientTLSOptions requires a recent-enough version of Twisted
  22 try:
  23 
  24     # taken from twisted/twisted/internet/_sslverify.py
  25     try:
  26         from OpenSSL.SSL import SSL_CB_HANDSHAKE_DONE, SSL_CB_HANDSHAKE_START
  27     except ImportError:
  28         SSL_CB_HANDSHAKE_START = 0x10
  29         SSL_CB_HANDSHAKE_DONE = 0x20
  30 
  31     from twisted.internet._sslverify import (ClientTLSOptions,
  32                                              _maybeSetHostNameIndication,
  33                                              verifyHostname,
  34                                              VerificationError)
  35 
  36     class ScrapyClientTLSOptions(ClientTLSOptions):
  37         # same as Twisted's ClientTLSOptions,
  38         # except that VerificationError is caught
  39         # and doesn't close the connection
  40         def _identityVerifyingInfoCallback(self, connection, where, ret):
  41             if where & SSL_CB_HANDSHAKE_START:
  42                 _maybeSetHostNameIndication(connection, self._hostnameBytes)
  43             elif where & SSL_CB_HANDSHAKE_DONE:
  44                 try:
  45                     verifyHostname(connection, self._hostnameASCII)
  46                 except VerificationError as e:
  47                     logger.warning(e)
  48 
  49 except ImportError:
  50     # ImportError should not matter for older Twisted versions
  51     # as the above is not used in the fallback ScrapyClientContextFactory
  52     pass
  53
  [end of scrapy/core/downloader/tls.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/scrapy/core/downloader/tls.py b/scrapy/core/downloader/tls.py
  --- a/scrapy/core/downloader/tls.py
  +++ b/scrapy/core/downloader/tls.py
  @@ -44,7 +44,9 @@
                   try:
                       verifyHostname(connection, self._hostnameASCII)
                   except VerificationError as e:
  -                    logger.warning(e)
  +                    logger.warning(
  +                        'Remote certificate is not valid for hostname "{}"; {}'.format(
  +                            self._hostnameASCII, e))
   
   except ImportError:
       # ImportError should not matter for older Twisted versions
  
verification_info: {"golden_diff": "diff --git a/scrapy/core/downloader/tls.py b/scrapy/core/downloader/tls.py\n--- a/scrapy/core/downloader/tls.py\n+++ b/scrapy/core/downloader/tls.py\n@@ -44,7 +44,9 @@\n                 try:\n                     verifyHostname(connection, self._hostnameASCII)\n                 except VerificationError as e:\n-                    logger.warning(e)\n+                    logger.warning(\n+                        'Remote certificate is not valid for hostname \"{}\"; {}'.format(\n+                            self._hostnameASCII, e))\n \n except ImportError:\n     # ImportError should not matter for older Twisted versions\n", "issue": "empty WARNING message in scrapy.core.downloader.tls (1.1.0rc4/master)\nSometimes I'm getting empty warnings now, on 1.1.0rc4 and master branch.\n(at least on rc3 as well)\n\n```\n2016-05-07 00:33:46 [scrapy.core.downloader.tls] WARNING: \n2016-05-07 00:33:47 [scrapy.core.downloader.tls] WARNING: \n2016-05-07 00:33:48 [scrapy.core.downloader.tls] WARNING: \n```\n\nIt happens in a broad linkcheck crawl; so I couldn't pinpoint what URLs might be responsible for that, at this time. The only other observation so far is, that it doesn't happen on a cache-replayed run (which might be obvious, as there is no TLS there).\n\n", "before_files": [{"content": "import logging\nfrom OpenSSL import SSL\n\n\nlogger = logging.getLogger(__name__)\n\nMETHOD_SSLv3 = 'SSLv3'\nMETHOD_TLS = 'TLS'\nMETHOD_TLSv10 = 'TLSv1.0'\nMETHOD_TLSv11 = 'TLSv1.1'\nMETHOD_TLSv12 = 'TLSv1.2'\n\nopenssl_methods = {\n    METHOD_TLS:    SSL.SSLv23_METHOD,                   # protocol negotiation (recommended)\n    METHOD_SSLv3:  SSL.SSLv3_METHOD,                    # SSL 3 (NOT recommended)\n    METHOD_TLSv10: SSL.TLSv1_METHOD,                    # TLS 1.0 only\n    METHOD_TLSv11: getattr(SSL, 'TLSv1_1_METHOD', 5),   # TLS 1.1 only\n    METHOD_TLSv12: getattr(SSL, 'TLSv1_2_METHOD', 6),   # TLS 1.2 only\n}\n\n# ClientTLSOptions requires a recent-enough version of Twisted\ntry:\n\n    # taken from twisted/twisted/internet/_sslverify.py\n    try:\n        from OpenSSL.SSL import SSL_CB_HANDSHAKE_DONE, SSL_CB_HANDSHAKE_START\n    except ImportError:\n        SSL_CB_HANDSHAKE_START = 0x10\n        SSL_CB_HANDSHAKE_DONE = 0x20\n\n    from twisted.internet._sslverify import (ClientTLSOptions,\n                                             _maybeSetHostNameIndication,\n                                             verifyHostname,\n                                             VerificationError)\n\n    class ScrapyClientTLSOptions(ClientTLSOptions):\n        # same as Twisted's ClientTLSOptions,\n        # except that VerificationError is caught\n        # and doesn't close the connection\n        def _identityVerifyingInfoCallback(self, connection, where, ret):\n            if where & SSL_CB_HANDSHAKE_START:\n                _maybeSetHostNameIndication(connection, self._hostnameBytes)\n            elif where & SSL_CB_HANDSHAKE_DONE:\n                try:\n                    verifyHostname(connection, self._hostnameASCII)\n                except VerificationError as e:\n                    logger.warning(e)\n\nexcept ImportError:\n    # ImportError should not matter for older Twisted versions\n    # as the above is not used in the fallback ScrapyClientContextFactory\n    pass\n", "path": "scrapy/core/downloader/tls.py"}]}