From ac2cf191d1868f19897a108a861e3170485a676a Mon Sep 17 00:00:00 2001 From: Konstantin Lopuhin Date: Thu, 14 Jan 2016 14:50:58 +0300 Subject: [PATCH] py3: remove comments, utf-8 is fine here: as twisted ultimately uses urllib.parse.quote that assepts bytes and assumes utf-8 --- scrapy/core/downloader/webclient.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/scrapy/core/downloader/webclient.py b/scrapy/core/downloader/webclient.py index 841322bdd..2d848aee0 100644 --- a/scrapy/core/downloader/webclient.py +++ b/scrapy/core/downloader/webclient.py @@ -12,13 +12,12 @@ from scrapy.responsetypes import responsetypes def _parsed_url_args(parsed): - b = lambda x: to_bytes(x, encoding='ascii') path = urlunparse(('', '', parsed.path or '/', parsed.params, parsed.query, '')) - path = to_bytes(path) # FIXME - host = b(parsed.hostname) # FIXME + path = to_bytes(path) + host = to_bytes(parsed.hostname) port = parsed.port - scheme = b(parsed.scheme) - netloc = b(parsed.netloc) # FIXME - host + port + scheme = to_bytes(parsed.scheme, encoding='ascii') + netloc = to_bytes(parsed.netloc) if port is None: port = 443 if scheme == b'https' else 80 return scheme, netloc, host, port, path @@ -96,7 +95,7 @@ class ScrapyHTTPClientFactory(HTTPClientFactory): def __init__(self, request, timeout=180): self._url = urldefrag(request.url)[0] # converting to bytes to comply to Twisted interface - self.url = to_bytes(self._url) # FIXME + self.url = to_bytes(self._url) self.method = to_bytes(request.method, encoding='ascii') self.body = request.body or None self.headers = Headers(request.headers)