diff --git a/contrib/win32/hg.bat b/contrib/win32/hg.bat
index f9b8ac279227fde0957d938dc88b83dee0dee572_Y29udHJpYi93aW4zMi9oZy5iYXQ=..6ec2e133d86f00f572f7d36cf6c2bdd038823786_Y29udHJpYi93aW4zMi9oZy5iYXQ= 100644
--- a/contrib/win32/hg.bat
+++ b/contrib/win32/hg.bat
@@ -4,8 +4,6 @@
 setlocal
 set HG=%~f0
 
-set PYTHONLEGACYWINDOWSSTDIO=1
-
 rem Use a full path to Python (relative to this script) if it exists,
 rem as the standard Python install does not put python.exe on the PATH...
 rem Otherwise, expect that python.exe can be found on the PATH.
diff --git a/mercurial/exewrapper.c b/mercurial/exewrapper.c
index f9b8ac279227fde0957d938dc88b83dee0dee572_bWVyY3VyaWFsL2V4ZXdyYXBwZXIuYw==..6ec2e133d86f00f572f7d36cf6c2bdd038823786_bWVyY3VyaWFsL2V4ZXdyYXBwZXIuYw== 100644
--- a/mercurial/exewrapper.c
+++ b/mercurial/exewrapper.c
@@ -47,10 +47,6 @@
 	void(__cdecl * Py_SetPythonHome)(TCHAR * home);
 	int(__cdecl * Py_Main)(int argc, TCHAR *argv[]);
 
-#if PY_MAJOR_VERSION >= 3
-	_wputenv(L"PYTHONLEGACYWINDOWSSTDIO=1");
-#endif
-
 	if (GetModuleFileName(NULL, pyscript, _countof(pyscript)) == 0) {
 		err = "GetModuleFileName failed";
 		goto bail;