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)
|
||||
# Find and call the right classmethod from_json() to restore the object.
|
||||
module = data['_module']
|
||||
m = __import__(module)
|
||||
for sub_module in module.split('.')[1:]:
|
||||
m = getattr(m, sub_module)
|
||||
m = __import__(module, fromlist=module.split('.')[:-1])
|
||||
kls = getattr(m, data['_class'])
|
||||
from_json = getattr(kls, 'from_json')
|
||||
return from_json(s)
|
||||
|
||||
Reference in New Issue
Block a user