# HG changeset patch # User Matt Harbison # Date 1629990254 14400 # Node ID 769cd5703b2ca501cb399986fbb3236574fec81f # Parent c1ed2c967facb2e422182fefc7336c499a5ca079 hg: don't attempt to extend `sys.path` with the user site without `APPDATA` 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, it was limited to the py2exe binary. As a precaution, fix both that and the pyoxidizer case that was causing the test to fail. Differential Revision: https://phab.mercurial-scm.org/D11354 diff -r c1ed2c967fac -r 769cd5703b2c hg --- a/hg Thu Aug 26 09:49:09 2021 +0200 +++ b/hg Thu Aug 26 11:04:14 2021 -0400 @@ -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 diff -r c1ed2c967fac -r 769cd5703b2c rust/hgcli/pyoxidizer.bzl --- a/rust/hgcli/pyoxidizer.bzl Thu Aug 26 09:49:09 2021 +0200 +++ b/rust/hgcli/pyoxidizer.bzl Thu Aug 26 11:04:14 2021 -0400 @@ -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;