Description
The log file to which stderr is redirected in boot_common.py
has a couple of issues that appear to have been inherited by the original py2 code from ~15 years ago.
-
Writing next to
sys.executable
will generally mean writing to%PROGRAMFILES%
, which UAC blocks when it is turned on. That results in losing the stderr output (unless the app is launched with Admin rights), as program output should go to%PROGRAMDATA%
. -
The
write()
method for the stream is supposed to return the number of characters written. Let patched sys.stderr.write() and sys.stdout.write() return number of written bytes #134 addresses this. -
It looks like the
write()
method on the redirected stream has a couple of default parameters that are non-standard, and not supplied anywhere in the codebase. I think they can be dropped.
I ended up implementing a workaround for this in TortoiseHg[1], but it would be better to have this upstream. Probably the trickiest part will be figuring out what subpath to write to under %PROGRAMDATA%
.
[1] https://foss.heptapod.net/mercurial/tortoisehg/thg/-/commit/15c88bb932f18c14f5d1ff6a277ebde5d722786e