D8022: chg: pass copies of some envvars so we can detect py37+ modifications

yuja (Yuya Nishihara) phabricator at mercurial-scm.org
Tue Jan 28 19:31:42 EST 2020


yuja added a comment.


  >   This would cause a difference in behavior between hg and chg. I don't know how big of an issue that would be.
  >   hg: starts up, python coerces LC_CTYPE, hg spawns a non-python subprocess, LC_CTYPE is set to the coerced value
  >   chg: starts up, python coerces LC_CTYPE, chg fixes it, hg spawns a non-python subprocess, LC_CTYPE is set to the original value (or unset).
  
  I think a minor behavior difference is acceptable. I see this is the problem
  of Python 3 design "the world is unicode", and IMHO we want to work around
  the problem with minimal changes.
  
  `PYTHONCOERCECLOCALE=0` was rejected because it may break Python subprocesses
  that expects the "coercing" will occur, but restoring the cheated `LC_CTYPE`
  should be fine. The chg behavior will be more correct, and non-Python
  subprocesses should work in the original "C" environment.
  
  >   Another case where it matters is: LC_CTYPE *is* important for hg when using any curses programs (or really anything that uses the locale module). If you are on a mac and set your region settings to have a region and a primary language that aren't representable using the locale settings (such as region = Brazil, language = English), then LC_CTYPE starts off as "UTF-8" (not "C.UTF-8"). This is allowed on macOS and I think other BSDs, but Linux doesn't like it. If the LC_CTYPE variable is forwarded when sshing to a Linux machine, this breaks curses. I'm sure this wasn't intentional, but the way that Python3.7 coerces the locale, it also happens to fix this particular issue and set it to C.UTF-8, which *does* work on Linux and makes `hg commit --interactive` with ui.interface=curses work; otherwise it gets a traceback.
  
  Does the curses depend on the locale environment variable, not on the
  `setlocale()`-ed process state?
  
  Anyway, I think this is an environment issue and it's totally fine for
  chg to crash (or abort) if the environment variable is incorrectly set.

REPOSITORY
  rHG Mercurial

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

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

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


More information about the Mercurial-devel mailing list