diff options
author | Victor Stinner <victor.stinner@enovance.com> | 2014-03-24 18:16:51 +0100 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2014-03-28 15:48:50 +0000 |
commit | 12f86fdcc57896bac62d36c74a80fd19adeeac58 (patch) | |
tree | edf38583f4ad8925e5d3b4162e77f4de13b9a1ed /swiftclient/client.py | |
parent | cdf6f84c360088d39af1b8e1745c102fc44ac362 (diff) | |
download | python-swiftclient-12f86fdcc57896bac62d36c74a80fd19adeeac58.tar.gz |
Python 3: Get compatible types from six
* Replace unicode with six.text_type
* Replace basestring with six.string_types
* The long type doesn't exist in Python 3 anymore: replace 1L with long(1) and
only test this type with Python 2
* Fix quote(): quote the URL if the string is a byte string. Use "bytes" type
instead of "str" to be Python 3 compatible.
Change-Id: I1df5aa85e4e7d07191fb5c654d52fc4bd8b9f440
Diffstat (limited to 'swiftclient/client.py')
-rw-r--r-- | swiftclient/client.py | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/swiftclient/client.py b/swiftclient/client.py index ad77817..c48f90f 100644 --- a/swiftclient/client.py +++ b/swiftclient/client.py @@ -28,6 +28,7 @@ from requests.exceptions import RequestException, SSLError from urllib import quote as _quote from urlparse import urlparse, urlunparse from time import sleep, time +import six from swiftclient.exceptions import ClientException, InvalidHeadersException from swiftclient.utils import LengthWrapper @@ -97,7 +98,7 @@ def quote(value, safe='/'): Patched version of urllib.quote that encodes utf8 strings before quoting """ value = encode_utf8(value) - if isinstance(value, str): + if isinstance(value, bytes): return _quote(value, safe) else: return value @@ -117,7 +118,7 @@ def validate_headers(headers): def encode_utf8(value): - if isinstance(value, unicode): + if isinstance(value, six.text_type): value = value.encode('utf8') return value |