Skip to content
This repository was archived by the owner on Jun 1, 2023. It is now read-only.

Commit 683d81e

Browse files
committed
Catch exception that is due to the fact that the input is str and not bytes.
1 parent 2a2b74a commit 683d81e

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

src/oidcmsg/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
__author__ = 'Roland Hedberg'
2-
__version__ = '0.3.1'
2+
__version__ = '0.3.2'

src/oidcmsg/message.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@
33
import json
44
import logging
55
from collections import MutableMapping
6-
from urllib.parse import urlencode, parse_qs
6+
from urllib.parse import parse_qs
7+
from urllib.parse import urlencode
78

9+
from cryptojwt import as_bytes
810
from cryptojwt import as_unicode
911
from cryptojwt import jwe
1012
from cryptojwt import jws
@@ -458,7 +460,12 @@ def from_json(self, txt, **kwargs):
458460
:param kwargs: extra keyword arguments
459461
:return: The instantiated instance
460462
"""
461-
return self.from_dict(json.loads(txt))
463+
try:
464+
_dict = json.loads(txt)
465+
except TypeError:
466+
_dict = json.loads(as_bytes(txt))
467+
468+
return self.from_dict(_dict)
462469

463470
def to_jwt(self, key=None, algorithm="", lev=0, lifetime=0):
464471
"""

0 commit comments

Comments
 (0)