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')