From patchwork Mon Sep 2 06:48:54 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: D6782: py3: use pycompat.sysargv[0] for instead of fsencode(sys.argv[0]) From: phabricator X-Patchwork-Id: 41463 Message-Id: To: Phabricator Cc: mercurial-devel@mercurial-scm.org Date: Mon, 2 Sep 2019 06:48:54 +0000 martinvonz created this revision. Herald added a subscriber: mercurial-devel. Herald added a reviewer: hg-reviewers. REVISION SUMMARY Yuya noted in a recent review that fsencode(sys.argv[0]) could be incorrect on Windows. REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D6782 AFFECTED FILES mercurial/utils/procutil.py CHANGE DETAILS To: martinvonz, #hg-reviewers Cc: mercurial-devel diff --git a/mercurial/utils/procutil.py b/mercurial/utils/procutil.py --- a/mercurial/utils/procutil.py +++ b/mercurial/utils/procutil.py @@ -245,8 +245,9 @@ 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 = (pycompat.fsencode(findexe('hg')) or + os.path.basename(pycompat.sysargv[0])) + _sethgexecutable(exe) return _hgexecutable def _sethgexecutable(path):