Using `six.raise_from` wherever possible.
diff --git a/google/auth/_oauth2client.py b/google/auth/_oauth2client.py
index 312326e..e298fb1 100644
--- a/google/auth/_oauth2client.py
+++ b/google/auth/_oauth2client.py
@@ -26,12 +26,14 @@
import google.oauth2.credentials
import google.oauth2.service_account
+import six
try:
import oauth2client.client
import oauth2client.contrib.gce
import oauth2client.service_account
-except ImportError:
- raise ImportError('oauth2client is not installed.')
+except ImportError as caught_exc:
+ new_exc = ImportError('oauth2client is not installed.')
+ six.raise_from(new_exc, caught_exc)
try:
import oauth2client.contrib.appengine
@@ -162,5 +164,6 @@
try:
return _CLASS_CONVERSION_MAP[credentials_class](credentials)
- except KeyError:
- raise ValueError(_CONVERT_ERROR_TMPL.format(credentials_class))
+ except KeyError as caught_exc:
+ new_exc = ValueError(_CONVERT_ERROR_TMPL.format(credentials_class))
+ six.raise_from(new_exc, caught_exc)