Skip to content

Commit 0e29e4f

Browse files
committed
Fix Issue #4746 by changing encoding of tempfile's to use locale.getpreferredencoding(False) instead of hardcoded utf-8
1 parent 94ad058 commit 0e29e4f

3 files changed

Lines changed: 11 additions & 1 deletion

File tree

CHANGES.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,11 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER
8282
windows-2022. The packaging tar bz2 and xz tests should be run on
8383
Windows 11 and GitHub windows-2025.
8484

85+
From William Deegan:
86+
- Fix Issue #4746. TEMPFILE's are written with utf-8 encoding, this doesn't work
87+
for all situations. Change to use locale.getpreferredencoding(False), which should
88+
yield the encoding for the system.
89+
8590
From Edward Peek:
8691
- Fix the variant dir component being missing from generated source file
8792
paths with CompilationDatabase() builder (Fixes #4003).

RELEASE.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,10 @@ FIXES
7676
- Fix a test problem on Windows where UNC tests failed due to incorrect path
7777
munging if a non-default %TEMP% was defined (as in moving to a Dev Drive).
7878

79+
- Fix Issue #4746. TEMPFILE's are written with utf-8 encoding, this doesn't work
80+
for all situations. Change to use locale.getpreferredencoding(False), which should
81+
yield the encoding for the system.
82+
7983
IMPROVEMENTS
8084
------------
8185

SCons/Platform/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
import os
4848
import sys
4949
import tempfile
50+
import locale
5051

5152
import SCons.Errors
5253
import SCons.Subst
@@ -279,7 +280,7 @@ def tmpfile_cleanup(file) -> None:
279280
tempfile_esc_func = env.get('TEMPFILEARGESCFUNC', SCons.Subst.quote_spaces)
280281
args = [tempfile_esc_func(arg) for arg in cmd[1:]]
281282
join_char = env.get('TEMPFILEARGJOIN', ' ')
282-
os.write(fd, bytearray(join_char.join(args) + "\n", encoding="utf-8"))
283+
os.write(fd, bytearray(join_char.join(args) + "\n", encoding=locale.getpreferredencoding(False)))
283284
os.close(fd)
284285

285286
# XXX Using the SCons.Action.print_actions value directly

0 commit comments

Comments
 (0)