From d6cca9a95015b8e5d0ebc29076d8e6eb7c0bbed8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20F=C3=A4hrmann?= Date: Sun, 10 Aug 2025 16:21:38 +0200 Subject: [PATCH] [scripts/pyprint] handle exception when all keys are > lmax --- scripts/pyprint.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/scripts/pyprint.py b/scripts/pyprint.py index 222849cb..621a0e19 100644 --- a/scripts/pyprint.py +++ b/scripts/pyprint.py @@ -61,10 +61,13 @@ def pyprint(obj, indent=0, sort=None, oneline=True, lmin=0, lmax=16): keys.sort() obj = {key: obj[key] for key in keys} - ws = " " * indent - keylen = max(kl for kl in map(len, obj) if kl <= lmax) + try: + keylen = max(kl for kl in map(len, obj) if kl <= lmax) + except Exception: + keylen = lmin if keylen < lmin: keylen = lmin + ws = " " * indent lines = ["{"] for key, value in obj.items():