Skip to content

Commit

Permalink
Merge #19750
Browse files Browse the repository at this point in the history
19750: dist/tools/usb-serial: Fix handling of None while quoting r=aabadie a=maribu

### Contribution description

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.


Co-authored-by: Marian Buschsieweke <marian.buschsieweke@posteo.net>
  • Loading branch information
bors[bot] and maribu authored Jun 22, 2023
2 parents 561e193 + 6192c62 commit 970734e
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion dist/tools/usb-serial/ttys.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 970734e

Please sign in to comment.