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

yuja (Yuya Nishihara) phabricator at mercurial-scm.org
Fri Dec 6 22:57:33 EST 2019


yuja added a comment.


  >   When the environment is empty (specifically: it doesn't contain LC_ALL,
  >   LC_CTYPE, or LANG), Python will "coerce" the locale environment variables to be
  >   a UTF-8 capable one. It sets LC_CTYPE in the environment, and this breaks chg,
  >   since chg operates by:
  >   - start hg, using whatever environment the user has when chg starts
  >   - hg stores a hash of this "original" environment, but python has already set LC_CTYPE even though the user doesn't have it in their environment
  >   - chg calls setenv over the commandserver. This clears the environment inside of hg and sets it to be exactly what the environment in chg is (without LC_CTYPE).
  >   - chg calls validate to ensure that the environment hg is using (after the setenv call) is the one that the chg process has - if not, it is assumed the user changed their environment and we should use a different server. This will *never* be true in this situation because LC_CTYPE was removed.
  
  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.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D7550/new/

REVISION DETAIL
  https://phab.mercurial-scm.org/D7550

To: spectral, #hg-reviewers
Cc: yuja, mjpieters, mercurial-devel


More information about the Mercurial-devel mailing list