[Updated] D10998: windows: replicate the normalizing behavior of os.environ
Alphare (Raphaël Gomès)
phabricator at mercurial-scm.org
Thu Jul 8 13:57:04 UTC 2021
Alphare edited the summary of this revision.
Alphare updated this revision to Diff 28999.
REPOSITORY
rHG Mercurial
CHANGES SINCE LAST UPDATE
https://phab.mercurial-scm.org/D10998?vs=28931&id=28999
BRANCH
default
CHANGES SINCE LAST ACTION
https://phab.mercurial-scm.org/D10998/new/
REVISION DETAIL
https://phab.mercurial-scm.org/D10998
AFFECTED FILES
mercurial/encoding.py
CHANGE DETAILS
diff --git a/mercurial/encoding.py b/mercurial/encoding.py
--- a/mercurial/encoding.py
+++ b/mercurial/encoding.py
@@ -338,10 +338,19 @@
if not _nativeenviron:
# now encoding and helper functions are available, recreate the environ
# dict to be exported to other modules
- environ = {
- tolocal(k.encode('utf-8')): tolocal(v.encode('utf-8'))
- for k, v in os.environ.items() # re-exports
- }
+ if pycompat.iswindows and pycompat.ispy3:
+
+ class WindowsEnviron(dict):
+ """`os.environ` normalizes environment variables to uppercase on windows"""
+
+ def get(self, key, default=None):
+ return super().get(upper(key), default)
+
+ environ = WindowsEnviron()
+
+ for k, v in os.environ.items(): # re-exports
+ environ[tolocal(k.encode('utf-8'))] = tolocal(v.encode('utf-8'))
+
if pycompat.ispy3:
# os.getcwd() on Python 3 returns string, but it has os.getcwdb() which
To: Alphare, #hg-reviewers
Cc: marmoute, mercurial-patches
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurial-scm.org/pipermail/mercurial-patches/attachments/20210708/bb9c5a71/attachment-0002.html>
More information about the Mercurial-patches
mailing list