[Updated] D11354: hg: don't attempt to extend `sys.path` with the user site without `APPDATA`

mharbison72 (Matt Harbison) phabricator at mercurial-scm.org
Fri Aug 27 09:26:44 UTC 2021


Closed by commit rHG769cd5703b2c: hg: don't attempt to extend `sys.path` with the user site without `APPDATA` (authored by mharbison72).
This revision was automatically updated to reflect the committed changes.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D11354?vs=30070&id=30076

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D11354/new/

REVISION DETAIL
  https://phab.mercurial-scm.org/D11354

AFFECTED FILES
  hg
  rust/hgcli/pyoxidizer.bzl

CHANGE DETAILS

diff --git a/rust/hgcli/pyoxidizer.bzl b/rust/hgcli/pyoxidizer.bzl
--- a/rust/hgcli/pyoxidizer.bzl
+++ b/rust/hgcli/pyoxidizer.bzl
@@ -47,14 +47,16 @@
 # Add user site to sys.path to load extensions without the full path
 if os.name == 'nt':
     vi = sys.version_info
-    sys.path.append(
-        os.path.join(
-            os.environ['APPDATA'],
-            'Python',
-            'Python%d%d' % (vi[0], vi[1]),
-            'site-packages',
+    appdata = os.environ.get('APPDATA')
+    if appdata:
+        sys.path.append(
+            os.path.join(
+                appdata,
+                'Python',
+                'Python%d%d' % (vi[0], vi[1]),
+                'site-packages',
+            )
         )
-    )
 import hgdemandimport;
 hgdemandimport.enable();
 from mercurial import dispatch;
diff --git a/hg b/hg
--- a/hg
+++ b/hg
@@ -28,14 +28,16 @@
 # to the documentation.
 if getattr(sys, 'frozen', None) == 'console_exe':
     vi = sys.version_info
-    sys.path.append(
-        os.path.join(
-            os.environ['APPDATA'],
-            'Python',
-            'Python%d%d' % (vi[0], vi[1]),
-            'site-packages',
+    appdata = os.environ.get('APPDATA')
+    if appdata:
+        sys.path.append(
+            os.path.join(
+                appdata,
+                'Python',
+                'Python%d%d' % (vi[0], vi[1]),
+                'site-packages',
+            )
         )
-    )
 
 from hgdemandimport import tracing
 



To: mharbison72, #hg-reviewers, Alphare
Cc: Alphare, mercurial-patches
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurial-scm.org/pipermail/mercurial-patches/attachments/20210827/1f8ea607/attachment-0002.html>


More information about the Mercurial-patches mailing list