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