mirror of https://github.com/explosion/spaCy.git
Fix Python2/3 load bug
This commit is contained in:
parent
5385a06dd2
commit
c8a58cfcf8
|
@ -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:
|
||||
|
|
|
@ -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 = {}
|
||||
|
@ -499,7 +499,7 @@ def model_from_bytes(model, bytes_data):
|
|||
for dim, value in weights[i]['dims'].items():
|
||||
setattr(layer, dim, value)
|
||||
for param in weights[i]['params']:
|
||||
dest = getattr(layer, param['name'])
|
||||
dest = getattr_(layer, param['name'])
|
||||
copy_array(dest, param['value'])
|
||||
i += 1
|
||||
if hasattr(layer, '_layers'):
|
||||
|
|
Loading…
Reference in New Issue