Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/encoding.py @ 51000:80c243eab724
openvms: duck-punch a bugfix into `environb` object
The official Python3 build for OpenVMS has some crippling bug that we need to
patch dynamically
OpenVMS patches
author | Jean-Francois Pieronne <jf.pieronne@laposte.net> |
---|---|
date | Thu, 03 Aug 2023 02:28:52 +0200 |
parents | 18c8c18993f0 |
children | 9d3721552b6c |
comparison
equal
deleted
inserted
replaced
50999:a97f2b50219b | 51000:80c243eab724 |
---|---|
77 # encoding.environ is provided read-only, which may not be used to modify | 77 # encoding.environ is provided read-only, which may not be used to modify |
78 # the process environment | 78 # the process environment |
79 _nativeenviron = os.supports_bytes_environ | 79 _nativeenviron = os.supports_bytes_environ |
80 if _nativeenviron: | 80 if _nativeenviron: |
81 environ = os.environb # re-exports | 81 environ = os.environb # re-exports |
82 if pycompat.sysplatform == b'OpenVMS': | |
83 # workaround for a bug in VSI 3.10 port | |
84 # os.environb is only populated with a few Predefined symbols | |
85 def newget(self, key, default=None): | |
86 # pytype on linux does not understand OpenVMS special modules | |
87 import _decc # pytype: disable=import-error | |
88 | |
89 v = _decc.getenv(key, None) | |
90 if isinstance(key, bytes): | |
91 return default if v is None else v.encode('latin-1') | |
92 else: | |
93 return default if v is None else v | |
94 | |
95 environ.__class__.get = newget | |
82 else: | 96 else: |
83 # preferred encoding isn't known yet; use utf-8 to avoid unicode error | 97 # preferred encoding isn't known yet; use utf-8 to avoid unicode error |
84 # and recreate it once encoding is settled | 98 # and recreate it once encoding is settled |
85 environ = { | 99 environ = { |
86 k.encode('utf-8'): v.encode('utf-8') | 100 k.encode('utf-8'): v.encode('utf-8') |