Add consvar for TEMPFILE encoding - #12
Merged
bdbaddog merged 3 commits intoAug 1, 2025
Merged
Conversation
….getpreferredencoding(False) instead of hardcoded utf-8
Alternate approach to avoid decoding problems: don't try to guess how to encode the TEMPFILE. Leave it utf-8 unless TEMPFILEENCODING is set. Add comment to TEMPFILEDIR doc on the topic as well. Signed-off-by: Mats Wichmann <mats@linux.com>
mwichmann
commented
Aug 1, 2025
| join_char = env.get('TEMPFILEARGJOIN', ' ') | ||
| os.write(fd, bytearray(join_char.join(args) + "\n", encoding="utf-8")) | ||
| encoding = env.get('TEMPFILEENCODING', 'utf-8') | ||
| os.write(fd, bytes(join_char.join(args) + "\n", encoding=encoding)) |
Author
There was a problem hiding this comment.
We're not going to change this - just immediately write it out - so there's no reason for it to be a bytearray.
| tempfile_dir = None | ||
|
|
||
| fd, tmp = tempfile.mkstemp(suffix, dir=tempfile_dir, text=True) | ||
| # default is binary - encode the tempfile contents later |
Author
There was a problem hiding this comment.
Seems wrong to open the file as text when we're explicitly going to write bytes. Risks unwanted conversion?
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 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.
Alternate approach to avoid decoding problems: don't try to guess how to encode the
TEMPFILE. Leave it utf-8 unlessTEMPFILEENCODINGis set.Add comment to
TEMPFILEDIRdoc on the topic as well.Updates SCons#4749
Signed-off-by: Mats Wichmann mats@linux.com