[PATCH] py3: handle os.environ.get() case in module loader
Siddharth Agarwal
sid at less-broken.com
Wed Aug 17 13:04:48 EDT 2016
On 8/4/16 20:26, Siddharth Agarwal wrote:
>
> I agree with Greg -- this makes things more complicated than
> necessary. We should just have a helper (e.g. util.environ) that gets
> assigned to os.environ on py2 and os.environb on py3. (And with
> possibly different behavior on Windows, similar to filenames.)
Pulkit asked me to elaborate a bit:
For Python 3 on Unix (including OS X), byte strings (UTF-8 encoded byte
strings on OS X) are as high fidelity a way to talk to the native OS
APIs as Unicode strings. So on Unix, you don't lose any information by
using os.environb versus os.environ.
For Python 3 on Windows, byte strings are a *lower* fidelity way to talk
to the native OS APIs than Unicode strings. So os.environb gives you
potentially less information than os.environ.
This behavior is identical to the way filesystem APIs work on Windows.
See https://www.mercurial-scm.org/wiki/WindowsUTF8Plan for how Mercurial
has tackled/plans to tackle this problem.
- Siddharth
More information about the Mercurial-devel
mailing list