Improve Python version error message for invisible Unicode whitespace #1947
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.
Looking through errors in Honeycomb I noticed some of the instances of builds failing due to an invalid Python version (in either their
.python-versionorruntime.txtfile) were due to leading/trailing invisible Unicode characters such as zero width space / zero width non-breaking space.Previously the error message for those was hard to understand, since the invisible nature of those characters mean they don't show up in the message, eg:
The reason for this is that
seduses the current locale, and so the[:space:]character class used by the sed call inutils::read_file_with_special_chars_substituted()was previously matching Unicode whitespace. (In contrast, the Bash extended regex used when parsing the read contents does not.)After this change, the unicode replacement character will now be shown (like it already is for other Unicode non-whitespace characters and ASCII control characters), eg:
See:
https://www.gnu.org/software/sed/manual/html_node/Locale-Considerations.html
GUS-W-20034162.