From f93a79aedde8883241b247244b4d15311ed2967a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Honza=20Kr=C3=A1l?= Date: Fri, 3 Oct 2014 17:32:11 +0200 Subject: [PATCH] Add explanation of url encoding --- elasticsearch/connection/http_urllib3.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/elasticsearch/connection/http_urllib3.py b/elasticsearch/connection/http_urllib3.py index 4d3592cc..d03b6620 100644 --- a/elasticsearch/connection/http_urllib3.py +++ b/elasticsearch/connection/http_urllib3.py @@ -40,8 +40,12 @@ class Urllib3HttpConnection(Connection): kw = {} if timeout: kw['timeout'] = timeout + + # in python2 we need to make sure the url is not unicode. Otherwise + # the body will be decoded into unicode too and that will fail (#133). if not isinstance(url, str): url = url.encode('utf-8') + response = self.pool.urlopen(method, url, body, retries=False, headers=self.headers, **kw) duration = time.time() - start raw_data = response.data.decode('utf-8')