Merge "Fix Pep8 Failures for Python3"
This commit is contained in:
commit
0d66f69b0c
@ -671,7 +671,9 @@ class BackupNFSSwiftBasedTestCase(test.TestCase):
|
||||
fake_data = bytearray(size)
|
||||
if six.PY2:
|
||||
# On Python 2, zlib.compressor() accepts buffer, but not bytearray
|
||||
fake_data = buffer(fake_data)
|
||||
# NOTE(jsbryant): Pep8 fails on py3 based installations as buffer()
|
||||
# was removed. 'noqa' used here to avoid that failure.
|
||||
fake_data = buffer(fake_data) # noqa
|
||||
return fake_data
|
||||
|
||||
def test_prepare_output_data_effective_compression(self):
|
||||
|
@ -427,7 +427,9 @@ def get_file_spec():
|
||||
file_spec = list(set(dir(_io.TextIOWrapper)).union(
|
||||
set(dir(_io.BytesIO))))
|
||||
else:
|
||||
file_spec = file
|
||||
# NOTE(jsbryant): Pep8 on py3 based systems will fail because
|
||||
# 'file' has been removed. Using noqa here to avoid the failure.
|
||||
file_spec = file # noqa
|
||||
|
||||
|
||||
def generate_timeout_series(timeout):
|
||||
|
@ -49,7 +49,7 @@ URI_TASKS_BY_OPID = '/vdc/tasks/{0}'
|
||||
def _decode_list(data):
|
||||
rv = []
|
||||
for item in data:
|
||||
if isinstance(item, unicode):
|
||||
if isinstance(item, six.text_type):
|
||||
item = item.encode('utf-8')
|
||||
elif isinstance(item, list):
|
||||
item = _decode_list(item)
|
||||
@ -62,9 +62,9 @@ def _decode_list(data):
|
||||
def _decode_dict(data):
|
||||
rv = {}
|
||||
for key, value in data.items():
|
||||
if isinstance(key, unicode):
|
||||
if isinstance(key, six.text_type):
|
||||
key = key.encode('utf-8')
|
||||
if isinstance(value, unicode):
|
||||
if isinstance(value, six.text_type):
|
||||
value = value.encode('utf-8')
|
||||
elif isinstance(value, list):
|
||||
value = _decode_list(value)
|
||||
@ -204,7 +204,7 @@ def service_json_request(ip_addr, port, http_method, uri, body,
|
||||
" service your request")
|
||||
else:
|
||||
error_msg = response.text
|
||||
if isinstance(error_msg, unicode):
|
||||
if isinstance(error_msg, six.text_type):
|
||||
error_msg = error_msg.encode('utf-8')
|
||||
raise CoprHdError(CoprHdError.HTTP_ERR,
|
||||
(_("HTTP code: %(status_code)s"
|
||||
|
Loading…
x
Reference in New Issue
Block a user