# HG changeset patch # User Jean-Francois Pieronne # Date 2023-08-03 00:28:52 # Node ID 80c243eab7245be34a3b1d25d71db86d6bc83b0e # Parent a97f2b50219bea50b6096e18a06c83323f79f126 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 diff --git a/mercurial/encoding.py b/mercurial/encoding.py --- a/mercurial/encoding.py +++ b/mercurial/encoding.py @@ -79,6 +79,20 @@ def hfsignoreclean(s): _nativeenviron = os.supports_bytes_environ if _nativeenviron: environ = os.environb # re-exports + if pycompat.sysplatform == b'OpenVMS': + # workaround for a bug in VSI 3.10 port + # os.environb is only populated with a few Predefined symbols + def newget(self, key, default=None): + # pytype on linux does not understand OpenVMS special modules + import _decc # pytype: disable=import-error + + v = _decc.getenv(key, None) + if isinstance(key, bytes): + return default if v is None else v.encode('latin-1') + else: + return default if v is None else v + + environ.__class__.get = newget else: # preferred encoding isn't known yet; use utf-8 to avoid unicode error # and recreate it once encoding is settled