From 72df17341dd15555aa4c7578c1f5ec716c275bba Mon Sep 17 00:00:00 2001 From: Jay Lee Date: Wed, 8 Jan 2020 06:55:37 -0500 Subject: [PATCH 1/3] Use collections.abc, fixes #418 --- google/auth/jwt.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/google/auth/jwt.py b/google/auth/jwt.py index a30c575b2..83e5e6398 100644 --- a/google/auth/jwt.py +++ b/google/auth/jwt.py @@ -40,7 +40,7 @@ """ -import collections +import collections.abc import copy import datetime import json @@ -215,7 +215,7 @@ def decode(token, certs=None, verify=True, audience=None): # If certs is specified as a dictionary of key IDs to certificates, then # use the certificate identified by the key ID in the token header. - if isinstance(certs, collections.Mapping): + if isinstance(certs, collections.abc.Mapping): key_id = header.get("kid") if key_id: if key_id not in certs: From c970aa2cba358d01fe3b2ba4a2a29e240a0ceaa1 Mon Sep 17 00:00:00 2001 From: Jay Lee Date: Fri, 17 Jan 2020 08:50:25 -0800 Subject: [PATCH 2/3] Python 2.7 compat fix --- google/auth/jwt.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/google/auth/jwt.py b/google/auth/jwt.py index 83e5e6398..17a48a0ff 100644 --- a/google/auth/jwt.py +++ b/google/auth/jwt.py @@ -40,7 +40,10 @@ """ -import collections.abc +try: + from collections.abc import Mapping +except ImportError: # Python 2.7 compatibility + from collections import Mapping import copy import datetime import json From a7d0154ed269e5cbd5af69c4bd63256f44b57545 Mon Sep 17 00:00:00 2001 From: Jay Lee Date: Fri, 17 Jan 2020 08:51:54 -0800 Subject: [PATCH 3/3] Fix check --- google/auth/jwt.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/google/auth/jwt.py b/google/auth/jwt.py index 17a48a0ff..361c4567a 100644 --- a/google/auth/jwt.py +++ b/google/auth/jwt.py @@ -218,7 +218,7 @@ def decode(token, certs=None, verify=True, audience=None): # If certs is specified as a dictionary of key IDs to certificates, then # use the certificate identified by the key ID in the token header. - if isinstance(certs, collections.abc.Mapping): + if isinstance(certs, Mapping): key_id = header.get("kid") if key_id: if key_id not in certs: