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

Change split strings to byte arrays for drive detection #14

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Change split strings to byte arrays for drive detection #14

wants to merge 1 commit into from

Conversation

oclyke
Copy link

@oclyke oclyke commented Dec 27, 2018

Using python 3.7.2 on Windows 10 (version 1803, build 17134.472, and running in Bootcamp) I repeatedly got the following error:

Converting to uf2, output size: 50176, start address: 0x8000000
Traceback (most recent call last):
  File "uf2conv.py", line 292, in <module>
    main()
  File "uf2conv.py", line 279, in main
    drives = get_drives()
  File "uf2conv.py", line 176, in get_drives
    for line in r.split('\n'):
TypeError: a bytes-like object is required, not 'str'

As well as a similar error for the regular expressions split line immediately following. Changing the split strings to byte array objects solved the problem for me, as shown in this commit

Using python 3.7.2 on Windows 10 (version 1803, build 17134.472, and running in Bootcamp) I repeatedly got the following error:

```
Converting to uf2, output size: 50176, start address: 0x8000000
Traceback (most recent call last):
  File "uf2conv.py", line 292, in <module>
    main()
  File "uf2conv.py", line 279, in main
    drives = get_drives()
  File "uf2conv.py", line 176, in get_drives
    for line in r.split('\n'):
TypeError: a bytes-like object is required, not 'str'
```
As well as a similar error for the regular expressions split line immediately following. Changing the split strings to byte array objects solved the problem for me, as shown in this commit
@pieterconradie
Copy link

pieterconradie commented Sep 10, 2019

The patch did not work for me. I am a Python novice, but found this solution that worked for me:

Change line 176 "for line in r.split('\n'):" to "for line in r.decode().split('\n'):"

The function call "decode()" changes the byte array to a string for further processing.

Hope that helps!

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.

2 participants