Undefined name 'unicode' in the new json methods

This commit is contained in:
Thomas Nagy 2015-11-21 17:17:16 +01:00
parent 0e03aec82d
commit 8113778aab
No known key found for this signature in database
GPG Key ID: 67A565EDFDF90E64
1 changed files with 6 additions and 2 deletions

View File

@ -167,12 +167,16 @@ class Node(object):
"""
import json # Python 2.6 and up
object_pairs_hook = None
if convert and sys.hexversion < 0x3000000:
try:
_type = unicode
except NameError:
_type = str
def convert(value):
if isinstance(value, list):
return [convert(element) for element in value]
elif isinstance(value, unicode):
elif isinstance(value, _type):
return str(value)
else:
return value