Skip to content

Fix error message formatting in uf2conv#106

Open
PetteriAimonen wants to merge 1 commit into
microsoft:masterfrom
PetteriAimonen:dev_fix_errmsg
Open

Fix error message formatting in uf2conv#106
PetteriAimonen wants to merge 1 commit into
microsoft:masterfrom
PetteriAimonen:dev_fix_errmsg

Conversation

@PetteriAimonen
Copy link
Copy Markdown

Some of the error messages were trying to concatenate int to str.
This gave error such as:


Traceback (most recent call last):
  File "uf2conv.py", line 363, in <module>
    main()
    ~~~~^^
  File "uf2conv.py", line 327, in main
    outbuf = convert_from_uf2(inpbuf)
  File "uf2conv.py", line 69, in convert_from_uf2
    assert False, "Block out of order at " + ptr
                  ~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~
TypeError: can only concatenate str (not "int") to str

Fixed the formatting and made the errors more helpful by including the addresses involved.

Converted the if foo: assert False construct to more idiomatic assert !foo. There is no performance penalty as Python does not evaluate the second argument of assert unless it fails.

Some of the error messages were trying to concatenate int to str.
This gave "TypeError: can only concatenate str (not "int") to str"

Fixed the formatting and made the errors more helpful by including
the addresses involved.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant