-
Notifications
You must be signed in to change notification settings - Fork 203
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
Fix UTF-8 encoding errors when running EasyBuild with Python 3.0.x-3.6.x #3565
Merged
Conversation
This file contains 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
Flamefire
force-pushed
the
utf8_fileread
branch
4 times, most recently
from
February 4, 2021 16:10
4b4df70
to
b8b12c8
Compare
Flamefire
changed the title
Add tests reproducing failure in handling UTF-8 files
Fix UTF-8 encoding errors on Python 3.0-3.6
Feb 4, 2021
boegel
requested changes
Feb 5, 2021
Flamefire
force-pushed
the
utf8_fileread
branch
from
February 8, 2021 11:26
6d4f3ba
to
bfa6c9c
Compare
boegel
requested changes
Feb 8, 2021
When the system encoding is not UTF-8 Python 3 will try to decode files as ASCII which fails This adds a test to CI with LC_ALL=C to enforce this situation and test cases reproducing failures in read_file, write_file and apply_regex_substitutions as seen in the wild
…ly_regex_substitutions
Flamefire
force-pushed
the
utf8_fileread
branch
from
February 8, 2021 12:54
83c146f
to
284167d
Compare
boegel
requested changes
Feb 9, 2021
boegel
changed the title
Fix UTF-8 encoding errors on Python 3.0-3.6
Fix UTF-8 encoding errors when running EasyBuild with Python 3.0.x-3.6.x
Feb 17, 2021
boegel
approved these changes
Feb 18, 2021
Flamefire
commented
Feb 18, 2021
Comment on lines
+1408
to
+1410
cache_dir = os.path.dirname(cache_fp) | ||
if not os.path.exists(cache_dir): | ||
mkdir(cache_dir, parents=True) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FTR: write_file already does this
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
When the system encoding is not UTF-8 Python 3 will try to decode files as ASCII which fails
This adds a test to CI with LC_ALL=C to enforce this situation and test cases reproducing failures in read_file, write_file and apply_regex_substitutions as seen in the wild
Example: easybuilders/easybuild-easyblocks#2279 the failing text is valid UTF-8 (likely)
It seems only Python 3 < 3.7 is affected because in 3.7 a "UTF-8" mode was introduced which opens files as UTF-8 by default: https://www.python.org/dev/peps/pep-0540/
Fixes easybuilders/easybuild-easyblocks#2279
fixed easybuilders/easybuild-easyblocks#2329
This change makes sure files are opened with utf-8 encoding in Python 3 (Python 2 doesn't really care). This applies to read_file/write_file and friends as well as the logger which also opens files and if no encoding is specified it will run into the same situation: It uses the default encoding which may be ASCII and then fail to log UTF-8 encoded strings. Example: Dumping an EC with an UTF-8 char in the description