Skip to content

Commit

Permalink
Merge pull request #4584 from siegria/fix_piped_spawn_encoding
Browse files Browse the repository at this point in the history
[Platform win32] Fix crash when pipe encoding is set to None
  • Loading branch information
bdbaddog authored Sep 3, 2024
2 parents 53d29af + b0342f5 commit b6c11d1
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
7 changes: 7 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER
will benefit from `TypeGuard`/`TypeIs`, to produce intellisense similar
to using `isinstance` directly.

From Anthony Siegrist;
- On win32 platform, handle piped process output more robustly. Output encoding
now uses 'oem' which should be the systems default encoding for the shell where
the process is being spawned.

From Mats Wichmann:
- env.Dump() now considers the "key" positional argument to be a varargs
type (zero, one or many). However called, it returns a serialized
Expand Down Expand Up @@ -46,6 +51,8 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER
a space character (issue #4585).




RELEASE 4.8.0 - Sun, 07 Jul 2024 17:22:20 -0700

From Joseph Brill:
Expand Down
9 changes: 9 additions & 0 deletions RELEASE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,15 @@ FIXES
- Fix handling of ListVariable when supplying a quoted choice containing
a space character (issue #4585).

- On win32 platform, SCons 4.7.0 modified the determination
of the output encoding of piped processes. Instead of using the default
encoding, it relied on the encoding attribute of the output stream.
If the encoding attribute of the output stream was set to None,
it was triggering an invalid argument exception. This was the case with
streams of type io.StringIO for example.
This has been changed to always use the `oem` encoding which should be the
encoding in the shell where the command was spawned.

IMPROVEMENTS
------------

Expand Down
4 changes: 2 additions & 2 deletions SCons/Platform/win32.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ def piped_spawn(sh, escape, cmd, args, env, stdout, stderr):
try:
with open(tmpFileStdoutName, "rb") as tmpFileStdout:
output = tmpFileStdout.read()
stdout.write(output.decode(stdout.encoding, "replace"))
stdout.write(output.decode('oem', "replace").replace("\r\n", "\n"))
os.remove(tmpFileStdoutName)
except OSError:
pass
Expand All @@ -176,7 +176,7 @@ def piped_spawn(sh, escape, cmd, args, env, stdout, stderr):
try:
with open(tmpFileStderrName, "rb") as tmpFileStderr:
errors = tmpFileStderr.read()
stderr.write(errors.decode(stderr.encoding, "replace"))
stderr.write(errors.decode('oem', "replace").replace("\r\n", "\n"))
os.remove(tmpFileStderrName)
except OSError:
pass
Expand Down

0 comments on commit b6c11d1

Please sign in to comment.