Repository navigation
Use UTF-8 when sorting simple YAML files - #1288
Closed
davrens101 wants to merge 1 commit into
Closed
davrens101 wants to merge 1 commit into
davrens101 wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
I reproduced sort-simple-yaml crashing on Windows 10, Python 3.12 with PYTHONUTF8=0 and the native cp1252 locale. A UTF-8 YAML value containing Н raises UnicodeDecodeError when the hook opens the file using the locale encoding.
I made the hook explicitly read and write UTF-8 and documented that encoding. The regression covers both already-sorted and unsorted input, including preservation of the Unicode value after rewriting. Both cases fail without the change. All 14 sort-simple-yaml tests and Flake8 checks pass with it. A separate native Windows reproduction without monkeypatches now sorts the file successfully.
I used cross-platform locale probing. This contribution was generated with AI assistance; I am not claiming human code review.