panphon
panphon copied to clipboard
Fixing encoding errors on windows
PR to address https://github.com/dmort27/panphon/issues/55.
This mainly adds the encoding='utf-8'
where appropriate so files open safely on Windows.
I also ran into a recursion error on test_featuretable.py. The issue appears to be a recursion problem in the SegmentSorter class. The segments property is calling sort_segments(), which in turn is accessing segments, creating an infinite loop. There, the changes made in featuretable.py are:
- Renamed sort_segments() to _sort_segments() to indicate it's a private method.
- In the segments property, we now call self._sort_segments() instead of self.sort_segments().
- In _sort_segments(), we set self._sorted = True after sorting.
All tests pass locally for me, on Mac and Windows.