Skip to content

windows: effect of PYTHONLEGACYWINDOWSSTDIO when not defined

Pierre Augier requested to merge topic/default/windows-legacystdio into branch/default

Fixes issue6952.

On Windows, we need PYTHONLEGACYWINDOWSSTDIO=1 so that the pager works correctly.

Normally, this environment variable is defined in hg.exe (see https://foss.heptapod.net/mercurial/mercurial-devel/-/blob/branch/default/mercurial/exewrapper.c?ref_type=heads#L51). However, there are situations for which this wrapper is not used (see https://bz.mercurial-scm.org/show_bug.cgi?id=6952).

Moreover, if we don't need this PYTHONLEGACYWINDOWSSTDIO=1 anymore, we can use a standard Python console-script entry point, which would simplify a lot of things.

I quickly tried this fix suggested by Steve Dower (CPython core developer) here on a PC on Windows 11 and it seems to work fine. However, I don't know all the implications of PYTHONLEGACYWINDOWSSTDIO and of this hack, so this needs to be seriously tested!

Note that it should have an effect only on Windows and only when PYTHONLEGACYWINDOWSSTDIO is not defined, i.e. only in quite rare cases (in particular hg installed with Pixi).

@mharbison72 I would be interested to have your point of view on this possible change.

Also I wonder if it's going to be used in the Windows CI. I know that the CI uses the wheel which lacks hg.exe so it well possible that this code is going to be used. I also wonder if the pager is tested during the CI...

Merge request reports

Loading