changeset 42860:db51a4ac85ac

py3: use pycompat.sysargv[0] for instead of fsencode(sys.argv[0]) Yuya noted in a recent review that fsencode(sys.argv[0]) could be incorrect on Windows. Differential Revision: https://phab.mercurial-scm.org/D6782
author Martin von Zweigbergk <martinvonz@google.com>
date Sun, 01 Sep 2019 23:43:59 -0700
parents 37debb6771f5
children 1fd530b1e1cf
files mercurial/utils/procutil.py
diffstat 1 files changed, 5 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/utils/procutil.py	Wed Sep 04 14:35:39 2019 -0700
+++ b/mercurial/utils/procutil.py	Sun Sep 01 23:43:59 2019 -0700
@@ -245,8 +245,11 @@
             pycompat.fsencode(getattr(mainmod, '__file__', ''))) == 'hg'):
             _sethgexecutable(pycompat.fsencode(mainmod.__file__))
         else:
-            exe = findexe('hg') or os.path.basename(sys.argv[0])
-            _sethgexecutable(pycompat.fsencode(exe))
+            exe = findexe('hg')
+            if exe:
+                _sethgexecutable(pycompat.fsencode(exe))
+            else:
+                _sethgexecutable(os.path.basename(pycompat.sysargv[0]))
     return _hgexecutable
 
 def _sethgexecutable(path):