From 25b515ed5a26f1048239ad703c9bd945cb6fd348 Mon Sep 17 00:00:00 2001 From: andrewkrug Date: Mon, 21 Aug 2017 15:07:30 -0700 Subject: [PATCH] to_dict method handles empty list case --- src/oic/oauth2/message.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/oic/oauth2/message.py b/src/oic/oauth2/message.py index 48dbde362..61b364b9d 100644 --- a/src/oic/oauth2/message.py +++ b/src/oic/oauth2/message.py @@ -319,7 +319,7 @@ def to_dict(self, lev=0): if isinstance(val, Message): _res[key] = val.to_dict(lev + 1) - elif isinstance(val, list) and isinstance(val[0], Message): + elif isinstance(val, list) and isinstance(next(iter(val or []), None), Message): _res[key] = [v.to_dict(lev) for v in val] else: _res[key] = val