From 155053ea61bb7a9afc19dc289886231e238bb298 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Mon, 31 Mar 2014 12:40:24 +0200 Subject: Fix swiftclient.client.quote() for Python 3 On Python 3, urllib.parse.quote() accepts bytes and str (unicode) types and always return str (unicode). Add also more tests with non-ASCII characters. Change-Id: I8e0f19da7240e874392327d0da074ed4abb7d213 --- swiftclient/client.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'swiftclient/client.py') diff --git a/swiftclient/client.py b/swiftclient/client.py index 01dbaa1..2766461 100644 --- a/swiftclient/client.py +++ b/swiftclient/client.py @@ -97,8 +97,11 @@ def http_log(args, kwargs, resp, body): def quote(value, safe='/'): """ - Patched version of urllib.quote that encodes utf8 strings before quoting + Patched version of urllib.quote that encodes utf8 strings before quoting. + On Python 3, call directly urllib.parse.quote(). """ + if six.PY3: + return _quote(value, safe=safe) value = encode_utf8(value) if isinstance(value, bytes): return _quote(value, safe) -- cgit v1.2.1