Skip to content

Commit 8c88c9e

Browse files
authored
Apply 'utf-8' encoding if encoding is set to None
As None is not a valid encoding value, fallback to 'utf-8'. This case happen if stdout or stderr is of type io.stringIO.
1 parent 876bb06 commit 8c88c9e

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

SCons/Platform/win32.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ def piped_spawn(sh, escape, cmd, args, env, stdout, stderr):
167167
try:
168168
with open(tmpFileStdoutName, "rb") as tmpFileStdout:
169169
output = tmpFileStdout.read()
170-
stdout.write(output.decode(stdout.encoding, "replace"))
170+
stdout.write(output.decode(stdout.encoding if stdout.encoding is not None else 'utf-8', "replace"))
171171
os.remove(tmpFileStdoutName)
172172
except OSError:
173173
pass
@@ -176,7 +176,7 @@ def piped_spawn(sh, escape, cmd, args, env, stdout, stderr):
176176
try:
177177
with open(tmpFileStderrName, "rb") as tmpFileStderr:
178178
errors = tmpFileStderr.read()
179-
stderr.write(errors.decode(stderr.encoding, "replace"))
179+
stderr.write(errors.decode(stderr.encoding if stderr.encoding is not None else 'utf-8', "replace"))
180180
os.remove(tmpFileStderrName)
181181
except OSError:
182182
pass

0 commit comments

Comments
 (0)