Directly import the target module in
oauth2client.client.Credentials.new_from_json. Reviewed in http://codereview.appspot.com/5085045/.
This commit is contained in:
@@ -143,9 +143,7 @@ class Credentials(object):
|
|||||||
data = simplejson.loads(s)
|
data = simplejson.loads(s)
|
||||||
# Find and call the right classmethod from_json() to restore the object.
|
# Find and call the right classmethod from_json() to restore the object.
|
||||||
module = data['_module']
|
module = data['_module']
|
||||||
m = __import__(module)
|
m = __import__(module, fromlist=module.split('.')[:-1])
|
||||||
for sub_module in module.split('.')[1:]:
|
|
||||||
m = getattr(m, sub_module)
|
|
||||||
kls = getattr(m, data['_class'])
|
kls = getattr(m, data['_class'])
|
||||||
from_json = getattr(kls, 'from_json')
|
from_json = getattr(kls, 'from_json')
|
||||||
return from_json(s)
|
return from_json(s)
|
||||||
|
|||||||
Reference in New Issue
Block a user