changeset 50995: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 a97f2b50219b
children 82bc0b26db50
files mercurial/encoding.py
diffstat 1 files changed, 14 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- 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