1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

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 <module>
        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.
This commit is contained in:
Marian Buschsieweke 2023-06-21 22:13:21 +02:00
parent 4deca3dfd7
commit 6192c620c8
No known key found for this signature in database
GPG Key ID: CB8E3238CE715A94

View File

@ -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