Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

utils/uf2conv.py: Fix padding with Python3 #71

Merged
merged 1 commit into from
May 17, 2023

Conversation

JohnAZoidberg
Copy link
Contributor

Reproduce with:

echo -n foo12345679 > foo
echo -n bar12345679 > bar

./utils/uf2conv.py foo -c -b 0x100 -o foo.uf2
./utils/uf2conv.py bar -c -b 0x1000 -o bar.uf2

cat foo.uf2 bar.uf2 > combined.uf2
./utils/uf2conv.py -i combined.uf2

Would fail like this

--- UF2 File Header Info ---
All block flag values consistent, 0x0000
----------------------------
Traceback (most recent call last):
  File "/home/zoid/clone/uf2/./utils/uf2conv.py", line 360, in <module>
    main()
  File "/home/zoid/clone/uf2/./utils/uf2conv.py", line 328, in main
    convert_from_uf2(inpbuf)
  File "/home/zoid/clone/uf2/./utils/uf2conv.py", line 109, in convert_from_uf2
    return b"".join(outp)
TypeError: sequence item 1: expected a bytes-like object, int found

Reproduce with:

```
echo -n foo12345679 > foo
echo -n bar12345679 > bar

./utils/uf2conv.py foo -c -b 0x100 -o foo.uf2
./utils/uf2conv.py bar -c -b 0x1000 -o bar.uf2

cat foo.uf2 bar.uf2 > combined.uf2
./utils/uf2conv.py -i combined.uf2
```

Would fail like this
```
--- UF2 File Header Info ---
All block flag values consistent, 0x0000
----------------------------
Traceback (most recent call last):
  File "/home/zoid/clone/uf2/./utils/uf2conv.py", line 360, in <module>
    main()
  File "/home/zoid/clone/uf2/./utils/uf2conv.py", line 328, in main
    convert_from_uf2(inpbuf)
  File "/home/zoid/clone/uf2/./utils/uf2conv.py", line 109, in convert_from_uf2
    return b"".join(outp)
TypeError: sequence item 1: expected a bytes-like object, int found
```

Signed-off-by: Daniel Schaefer <[email protected]>
JohnAZoidberg added a commit to FrameworkComputer/qmk_firmware that referenced this pull request Jan 16, 2023
@vkottler
Copy link

I did a large refactor of this code here as well: #42 (comment).

@mmoskal mmoskal merged commit 3419a7b into microsoft:master May 17, 2023
@mmoskal
Copy link
Member

mmoskal commented May 17, 2023

thank you!

@JohnAZoidberg JohnAZoidberg deleted the python3-padding branch July 14, 2023 07:48
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.

3 participants