From 2d467ea6c6d5636be860c6df7926f50aaa89e94e Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Mon, 6 Oct 2014 08:22:25 +0200 Subject: [PATCH] fix utf-8 urls --- ox/net.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/ox/net.py b/ox/net.py index cb9c613..8706247 100644 --- a/ox/net.py +++ b/ox/net.py @@ -52,8 +52,12 @@ def get_json(url, data=None, headers=DEFAULT_HEADERS): return json.loads(read_url(url, data, headers).decode('utf-8')) def open_url(url, data=None, headers=DEFAULT_HEADERS): - if isinstance(url, bytes): - url = url.decode('utf-8') + if PY3: + if isinstance(url, bytes): + url = url.decode('utf-8') + else: + if not isinstance(url, bytes): + url = url.encode('utf-8') url = url.replace(' ', '%20') if data and PY3 and not isinstance(data, bytes): data = data.encode('utf-8')