Merge for updated requirements

This commit is contained in:
Matthew Honnibal 2017-06-01 04:57:26 -05:00
commit 3ff7d7fcef
2 changed files with 7 additions and 2 deletions

View File

@ -59,6 +59,11 @@ elif is_python3:
json_dumps = lambda data: ujson.dumps(data, indent=2)
path2str = lambda path: str(path)
def getattr_(obj, name, *default):
if is_python3 and isinstance(name, bytes):
name = name.decode('utf8')
return getattr(obj, name, *default)
def symlink_to(orig, dest):
if is_python2 and is_windows:
@ -79,7 +84,7 @@ def is_config(python2=None, python3=None, windows=None, linux=None, osx=None):
def normalize_string_keys(old):
'''Given a dictionary, make sure keys are unicode strings, not bytes.'''
new = {}
for key, value in old:
for key, value in old.items():
if isinstance(key, bytes_):
new[key.decode('utf8')] = value
else:

View File

@ -22,7 +22,7 @@ import ujson
from .symbols import ORTH
from .compat import cupy, CudaStream, path2str, basestring_, input_, unicode_
from .compat import copy_array, normalize_string_keys
from .compat import copy_array, normalize_string_keys, getattr_
LANGUAGES = {}