py3: use pycompat.sysargv in scmposix.systemrcpath()
sys.argv returns unicodes on Python 3. We have pycompat.sysargv which returns
bytes encoded using os.fsencode(). After this patch scmposix.systemrcpath()
returns bytes in Python 3 world. This change is also a part of making
`hg version` run in Python 3.
--- a/mercurial/scmposix.py Sun Nov 20 13:50:45 2016 -0800
+++ b/mercurial/scmposix.py Mon Nov 21 15:26:47 2016 +0530
@@ -9,6 +9,7 @@
from . import (
encoding,
osutil,
+ pycompat,
)
def _rcfiles(path):
@@ -30,7 +31,7 @@
root = 'etc/mercurial'
# old mod_python does not set sys.argv
if len(getattr(sys, 'argv', [])) > 0:
- p = os.path.dirname(os.path.dirname(sys.argv[0]))
+ p = os.path.dirname(os.path.dirname(pycompat.sysargv[0]))
if p != '/':
path.extend(_rcfiles(os.path.join(p, root)))
path.extend(_rcfiles('/' + root))