Skip to content

Commit 6df57d2

Browse files
committed
SCons: Fix silence_msvc regression
1 parent 2886511 commit 6df57d2

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

platform/windows/detect.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -411,10 +411,13 @@ def spawn_capture(sh, escape, cmd, args, env):
411411
ret = old_spawn(sh, escape, cmd, args, env)
412412

413413
try:
414-
with open(tmp_stdout_name, "rt", encoding=sys.stdout.encoding) as tmp_stdout:
415-
# First line is always bloat, subsequent lines are always errors. This filter sends
416-
# either just the errors to stderr, or an empty string to effectively do nothing.
417-
sys.stderr.write("".join(tmp_stdout.readlines()[1:]))
414+
with open(tmp_stdout_name, "rb") as tmp_stdout:
415+
# First line is always bloat, subsequent lines are always errors. If content
416+
# exists after discarding the first line, safely decode & send to stderr.
417+
tmp_stdout.readline()
418+
content = tmp_stdout.read()
419+
if content:
420+
sys.stderr.write(content.decode(sys.stdout.encoding, "replace"))
418421
os.remove(tmp_stdout_name)
419422
except OSError:
420423
pass

0 commit comments

Comments
 (0)