diff --git a/mercurial/exewrapper.c b/mercurial/exewrapper.c --- a/mercurial/exewrapper.c +++ b/mercurial/exewrapper.c @@ -7,6 +7,7 @@ GNU General Public License version 2 or any later version. */ +#include #include #include #include @@ -46,6 +47,10 @@ int _tmain(int argc, TCHAR *argv[]) void(__cdecl * Py_SetPythonHome)(TCHAR * home); int(__cdecl * Py_Main)(int argc, TCHAR *argv[]); +#if PY_MAJOR_VERSION >= 3 + Py_LegacyWindowsStdioFlag = 1; +#endif + if (GetModuleFileName(NULL, pyscript, _countof(pyscript)) == 0) { err = "GetModuleFileName failed"; goto bail; diff --git a/tests/run-tests.py b/tests/run-tests.py --- a/tests/run-tests.py +++ b/tests/run-tests.py @@ -2640,6 +2640,10 @@ class TestRunner(object): self._tmpbindir = self._bindir self._pythondir = os.path.join(self._installdir, b"lib", b"python") + # Force the use of hg.exe instead of relying on MSYS to recognize hg is + # a python script and feed it to python.exe. Legacy stdio is force + # enabled by hg.exe, and this is a more realistic way to launch hg + # anyway. if os.name == 'nt' and not self._hgcommand.endswith(b'.exe'): self._hgcommand += b'.exe'