spack_json: _strify should be a no-op in Python 3
_strify traverses *all* of the read-in data and converts strings, but only for Python 2. Ignore it in Python 3.
This commit is contained in:
parent
52508e6ee7
commit
e3e913ef8f
@ -38,10 +38,14 @@ def dump(data, stream=None):
|
|||||||
|
|
||||||
|
|
||||||
def _strify(data, ignore_dicts=False):
|
def _strify(data, ignore_dicts=False):
|
||||||
|
"""Converts python 2 unicodes to str in JSON data."""
|
||||||
|
# this is a no-op in python 3
|
||||||
|
if sys.version_info[0] >= 3:
|
||||||
|
return data
|
||||||
|
|
||||||
# if this is a unicode string in python 2, return its string representation
|
# if this is a unicode string in python 2, return its string representation
|
||||||
if sys.version_info[0] < 3:
|
if isinstance(data, string_types):
|
||||||
if isinstance(data, string_types):
|
return data.encode('utf-8')
|
||||||
return data.encode('utf-8')
|
|
||||||
|
|
||||||
# if this is a list of values, return list of byteified values
|
# if this is a list of values, return list of byteified values
|
||||||
if isinstance(data, list):
|
if isinstance(data, list):
|
||||||
|
Loading…
Reference in New Issue
Block a user