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

mharbison72 (Matt Harbison) phabricator at mercurial-scm.org
Thu Aug 26 15:19:32 UTC 2021


mharbison72 created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  This variable is created by the system and *should* be available, but
  test-lfs-bundle.t has a test where it is explicitly unset.  It wasn't caught
  before because prior to 95af358fcdfe <https://phab.mercurial-scm.org/rHG95af358fcdfe12e2241f52575a143a8c7efac10e>, it was limited to the py2exe binary.  As a
  precaution, fix both that and the pyoxidizer case that was causing the test to
  fail.

REPOSITORY
  rHG Mercurial

BRANCH
  stable

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
Cc: mercurial-patches, mercurial-devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mercurial-scm.org/pipermail/mercurial-patches/attachments/20210826/c6d9da4f/attachment.html>


More information about the Mercurial-patches mailing list