Python 3: Fix basestring, long and StringIO
* The basestring type was removed in Python 3: replace it with six.string_types. * Replace StringIO.StringIO with six.StringIO * Replace (int, long) with six.integer_types Change-Id: Ic0d443b0bdd00fb18452e79ffae07b9be0fa8116
This commit is contained in:
parent
c0217a4845
commit
a60096769c
@ -297,11 +297,11 @@ def parse_and_validate_input(req_body, req_path):
|
|||||||
for ek in sorted(extraneous_keys))))
|
for ek in sorted(extraneous_keys))))
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if not isinstance(seg_dict['path'], basestring):
|
if not isinstance(seg_dict['path'], six.string_types):
|
||||||
errors.append("Index %d: \"path\" must be a string" % seg_index)
|
errors.append("Index %d: \"path\" must be a string" % seg_index)
|
||||||
continue
|
continue
|
||||||
if not (seg_dict['etag'] is None or
|
if not (seg_dict['etag'] is None or
|
||||||
isinstance(seg_dict['etag'], basestring)):
|
isinstance(seg_dict['etag'], six.string_types)):
|
||||||
errors.append(
|
errors.append(
|
||||||
"Index %d: \"etag\" must be a string or null" % seg_index)
|
"Index %d: \"etag\" must be a string or null" % seg_index)
|
||||||
continue
|
continue
|
||||||
|
@ -284,7 +284,7 @@ def _resp_status_property():
|
|||||||
return '%s %s' % (self.status_int, self.title)
|
return '%s %s' % (self.status_int, self.title)
|
||||||
|
|
||||||
def setter(self, value):
|
def setter(self, value):
|
||||||
if isinstance(value, (int, long)):
|
if isinstance(value, six.integer_types):
|
||||||
self.status_int = value
|
self.status_int = value
|
||||||
self.explanation = self.title = RESPONSE_REASONS[value][0]
|
self.explanation = self.title = RESPONSE_REASONS[value][0]
|
||||||
else:
|
else:
|
||||||
|
@ -964,7 +964,7 @@ def decode_timestamps(encoded, explicit=False):
|
|||||||
# TODO: some tests, e.g. in test_replicator, put float timestamps values
|
# TODO: some tests, e.g. in test_replicator, put float timestamps values
|
||||||
# into container db's, hence this defensive check, but in real world
|
# into container db's, hence this defensive check, but in real world
|
||||||
# this may never happen.
|
# this may never happen.
|
||||||
if not isinstance(encoded, basestring):
|
if not isinstance(encoded, six.string_types):
|
||||||
ts = Timestamp(encoded)
|
ts = Timestamp(encoded)
|
||||||
return ts, ts, ts
|
return ts, ts, ts
|
||||||
|
|
||||||
|
@ -17,8 +17,8 @@
|
|||||||
import os
|
import os
|
||||||
import json
|
import json
|
||||||
import mock
|
import mock
|
||||||
|
from six import StringIO
|
||||||
import unittest
|
import unittest
|
||||||
from StringIO import StringIO
|
|
||||||
from test.unit import with_tempdir
|
from test.unit import with_tempdir
|
||||||
|
|
||||||
from swift.cli.ring_builder_analyzer import parse_scenario, run_scenario
|
from swift.cli.ring_builder_analyzer import parse_scenario, run_scenario
|
||||||
|
Loading…
Reference in New Issue
Block a user