D7550: chg: fix chg to work with py3.7+ "coercing" the locale

Yuya Nishihara yuya at tcha.org
Thu Dec 12 09:03:45 EST 2019

>   > Sigh. Can we work around this weird behavior by making chg do
>   > `putenv("PYTHONCOERCECLOCALE=0")`? I think it's simple and more desired
>   > behavior than the default of Python 3.
>   I had considered that and was concerned it would create an observable, surprising/confusing difference between chg and non-chg: if chg sets PYTHONCOERCECLOCALE=0, hg won't have LC_CTYPE in the environment, and it WILL have PYTHONCOERCECLOCALE in the environment. When it starts external tools (like merge tools), this may change behavior in some observable fashion, and if the user stops using chg and uses just plain hg, it will have LC_CTYPE in the environment.

Yeah, that could happen. I checked the CPython code, but there's no easy way
to disable PYTHONCOERCECLOCALE at all without writing a C wrapper or rebuilding
Python itself with --without-c-locale-coercion.

I don't care much about the pollution of subprocess environments since Python
does pollute LC_CTYPE by default, which is IMHO worse, but I agree it isn't
nice to introduce behavior change between pure hg and chg. So we'll have to
take this patch, sigh.

Queued, thanks.

More information about the Mercurial-devel mailing list