From 6192c620c806781931c3465c6745767ad0a8ccd4 Mon Sep 17 00:00:00 2001 From: Marian Buschsieweke Date: Wed, 21 Jun 2023 22:13:21 +0200 Subject: [PATCH] dist/tools/usb-serial: Fix handling of None while quoting This fixes: Traceback (most recent call last): File "/home/maribu/Repos/software/RIOT/master/dist/tools/usb-serial/ttys.py", line 259, in print_ttys(sys.argv) File "/home/maribu/Repos/software/RIOT/master/dist/tools/usb-serial/ttys.py", line 255, in print_ttys print_results(args, ttys) File "/home/maribu/Repos/software/RIOT/master/dist/tools/usb-serial/ttys.py", line 189, in print_results if item.rfind(args.format_sep) >= 0: ^^^^^^^^^^ AttributeError: 'NoneType' object has no attribute 'rfind' Which occurs while testing whether a string requires special quoting if an attribute is None. --- dist/tools/usb-serial/ttys.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dist/tools/usb-serial/ttys.py b/dist/tools/usb-serial/ttys.py index fbf1ff904099..38b6ed3415ac 100755 --- a/dist/tools/usb-serial/ttys.py +++ b/dist/tools/usb-serial/ttys.py @@ -186,7 +186,7 @@ def print_results(args, ttys): line = "" for fmt in args.format: item = tty[fmt] - if item.rfind(args.format_sep) >= 0: + if item is not None and item.rfind(args.format_sep) >= 0: # item contains separator --> quote it # using json.dumps to also escape quotation chars and other # unsafe stuff