diff --git a/tools/maint/run_python.bat b/tools/maint/run_python.bat index e9080623b77f0..9170dae6f949b 100644 --- a/tools/maint/run_python.bat +++ b/tools/maint/run_python.bat @@ -2,8 +2,8 @@ :: :: Automatically generated by `create_entry_points.py`; DO NOT EDIT. :: -:: To make modifications to this file, edit `tools\run_python.bat` and then run -:: `tools\maint\create_entry_points.py` +:: To make modifications to this file, edit `tools\maint\run_python.bat` and +:: then run `tools\maint\create_entry_points.py` :: N.b. In Windows .bat scripts, the ':' character cannot appear inside any if () blocks, :: or there will be a parsing error. @@ -70,17 +70,24 @@ ) ) +:: N.b. when passing the -E flag to Python (ignore PYTHON* environment +:: variables (such as PYTHONPATH)), Python will revert to cp1252 encoding +:: on Windows by default, if stdout/stderr is redirected. +:: https://github.com/buildbot/buildbot/issues/9047 +:: To avoid this from causing issues, explicitly specify the -X utf8 encoding +:: on tool invocations. + :NORMAL_EXIT -@"%_EM_PY%" -E "%MYDIR%%~n0.py" %* +@"%_EM_PY%" -E -X utf8 "%MYDIR%%~n0.py" %* @exit %ERRORLEVEL% :MUTE_STDIN -@"%_EM_PY%" -E "%MYDIR%%~n0.py" %* < NUL +@"%_EM_PY%" -E -X utf8 "%MYDIR%%~n0.py" %* < NUL @exit /b %ERRORLEVEL% :MUTE_STDIN_EXIT -@"%_EM_PY%" -E "%MYDIR%%~n0.py" %* < NUL +@"%_EM_PY%" -E -X utf8 "%MYDIR%%~n0.py" %* < NUL @exit %ERRORLEVEL% :NORMAL -@"%_EM_PY%" -E "%MYDIR%%~n0.py" %* +@"%_EM_PY%" -E -X utf8 "%MYDIR%%~n0.py" %* diff --git a/tools/maint/run_python_compiler.bat b/tools/maint/run_python_compiler.bat index dd5aa6565a35b..0d4c95fb90860 100644 --- a/tools/maint/run_python_compiler.bat +++ b/tools/maint/run_python_compiler.bat @@ -39,10 +39,17 @@ ) :FOUND_MYDIR +:: N.b. when passing the -E flag to Python (ignore PYTHON* environment +:: variables (such as PYTHONPATH)), Python will revert to cp1252 encoding +:: on Windows by default, if stdout/stderr is redirected. +:: https://github.com/buildbot/buildbot/issues/9047 +:: To avoid this from causing issues, explicitly specify the -X utf8 encoding +:: on tool invocations. + :: If _EMCC_CCACHE is not set, do a regular invocation of the python compiler driver. :: Otherwise remove the ccache env. var, and then reinvoke this script with ccache enabled. @if "%_EMCC_CCACHE%"=="" ( - set CMD="%_EM_PY%" -E "%MYDIR%%~n0.py" + set CMD="%_EM_PY%" -E -X utf8 "%MYDIR%%~n0.py" ) else ( set _EMCC_CCACHE= set CMD=ccache "%MYDIR%%~n0.bat"