# HG changeset patch # User Jean-Francois Pieronne # Date 1691022532 -7200 # 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 -r a97f2b50219b -r 80c243eab724 mercurial/encoding.py --- a/mercurial/encoding.py Wed Oct 11 00:43:24 2023 +0200 +++ b/mercurial/encoding.py Thu Aug 03 02:28:52 2023 +0200 @@ -79,6 +79,20 @@ _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