Scrapy, a fast high-level web crawling & scraping framework for Python.
py3: remove comments, utf-8 is fine here: as twisted ultimately uses urllib.parse.quote that assepts bytes and assumes utf-8
Konstantin Lopuhinac2cf191d186
diff --git a/scrapy/core/downloader/webclient.py b/scrapy/core/downloader/webclient.pyindex 841322bdd..2d848aee0 100644--- a/scrapy/core/downloader/webclient.py+++ b/scrapy/core/downloader/webclient.py@@ -12,13 +12,12 @@ from scrapy.responsetypes import responsetypesdef _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 80return 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 Noneself.headers = Headers(request.headers)