Python 3: use six.iteritems and six.string_types

six.iteritems() replaces dictionary.iteritems() on Python 2 and
dictionary.items() on Python 3.

six.string_types replaces basestring() in Python 2 and str
in Python 3.

Change-Id: Ia18510d167df35caec83626718010228e2140bc0
This commit is contained in:
Yassine Lamgarchal
2014-01-10 11:13:21 +01:00
parent 47de9cfd89
commit 02b00b6226
4 changed files with 11 additions and 9 deletions
+2 -2
View File
@@ -83,7 +83,7 @@ class ImageManager(base.Manager):
# headers will be encoded later, before the
# request is sent.
def to_str(value):
if not isinstance(value, basestring):
if not isinstance(value, six.string_types):
return str(value)
return value
@@ -162,7 +162,7 @@ class ImageManager(base.Manager):
owner = qp.pop('owner', None)
for param, value in six.iteritems(qp):
if isinstance(value, basestring):
if isinstance(value, six.string_types):
# Note(flaper87) Url encoding should
# be moved inside http utils, at least
# shouldn't be here.