Thanks to visit codestin.com
Credit goes to github.com

Skip to content

makeqstrdata: Work around python3.5/3.6 compatibility problem #3446

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

Merged
merged 1 commit into from
Sep 21, 2020

Conversation

jepler
Copy link

@jepler jepler commented Sep 21, 2020

Discord user Folknology encountered a problem building with Python 3.6.9, TypeError: ord() expected a character, but string of length 0 found.

I was able to reproduce the problem using Python3.5*, and discovered that the meaning of the regular expression "|." had changed in 3.7. Before,

>>> [m.group(0) for m in re.finditer("|.", "hello")]
['', '', '', '', '', '']

After:

>>> [m.group(0) for m in re.finditer("|.", "hello")]
['', 'h', '', 'e', '', 'l', '', 'l', '', 'o', '']

Check if words is empty and if so use "." as the regular expression instead. This gives the same result on both versions:

['h', 'e', 'l', 'l', 'o']

and fixes the generation of the huffman dictionary.

Folknology verified that this fix worked for them.

  • I could easily install 3.5 but not 3.6. 3.5 reproduced the same problem

Discord user Folknology encountered a problem building with Python 3.6.9,
`TypeError: ord() expected a character, but string of length 0 found`.

I was able to reproduce the problem using Python3.5*, and discovered that
the meaning of the regular expression `"|."` had changed in 3.7.  Before,
```
>>> [m.group(0) for m in re.finditer("|.", "hello")]
['', '', '', '', '', '']
```
After:
```
>>> [m.group(0) for m in re.finditer("|.", "hello")]
['', 'h', '', 'e', '', 'l', '', 'l', '', 'o', '']
```
Check if `words` is empty and if so use `"."` as the regular expression
instead.  This gives the same result on both versions:
```
['h', 'e', 'l', 'l', 'o']
```
and fixes the generation of the huffman dictionary.

Folknology verified that this fix worked for them.

 * I could easily install 3.5 but not 3.6.  3.5 reproduced the same problem
@jepler
Copy link
Author

jepler commented Sep 21, 2020

@ciscorn this was fun

@jepler jepler requested a review from dhalbert September 21, 2020 15:05
@jepler
Copy link
Author

jepler commented Sep 21, 2020

@dhalbert another fix it would be nice to get into beta.0

@jepler jepler requested review from tannewt and removed request for dhalbert September 21, 2020 15:35
Copy link
Member

@tannewt tannewt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@tannewt tannewt merged commit df067b4 into adafruit:main Sep 21, 2020
@jepler jepler deleted the python35-compression-fix branch November 3, 2021 21:10
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