Three small fixes for panphon on Windows and Python 3.12 #59
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Three small fixes for panphon on Windows and Python 3.12:
On Python 3.12, I was getting infinite recursion in featuretable.py because sort_segments() used self.segments which called segments() and thus sort_segments() again. Using the underlying self._segments instead in sort_segments() removes the infinite recursion.
Also in featuretable.py,
with open(fn) as f:
on line 79 assumes utf-8 on Linux, but it assumes cp-1252 on my Windows machine. Declaring the encoding explicitly fixed the problem. For code portability, it's unfortunately and very annoyingly required to always declare the encoding when opening a file in text mode in Python.There are other places in the code where text-mode open statements don't declare the encoding. I'm not sure why those did not cause problems in my tests.
Minor warning from Python 3.12: in the docstring, the \ in \w has to be escaped so that
help(Segments)
get printed correctly.I have tested these changes with python 3.8 and python 3.12 on a machine with Windows 10, using
python -m unittest panphon/test/test*
to run all unit tests.I discovered these problems while testing #57 on my machine. Note that this PR includes the commit from #57 because without it I could not test on Python 3.8.