[PATCH 7 of 7] py3: replace sys.executable with pycompat.sysexecutable

Pulkit Goyal 7895pulkit at gmail.com
Wed Dec 21 17:03:52 EST 2016


# HG changeset patch
# User Pulkit Goyal <7895pulkit at gmail.com>
# Date 1482173407 -19800
#      Tue Dec 20 00:20:07 2016 +0530
# Node ID 681d2b64c89648c395c2af97062c94d1238c510d
# Parent  11739d0ee458863d90e44c258b9773ca2e0a605a
py3: replace sys.executable with pycompat.sysexecutable

sys.executable returns unicodes on Python 3. This patch replaces occurences of
sys.executable with pycompat.sysexecutable.

diff -r 11739d0ee458 -r 681d2b64c896 mercurial/chgserver.py
--- a/mercurial/chgserver.py	Tue Dec 20 00:02:24 2016 +0530
+++ b/mercurial/chgserver.py	Tue Dec 20 00:20:07 2016 +0530
@@ -47,7 +47,6 @@
 import re
 import signal
 import struct
-import sys
 import time
 
 from .i18n import _
@@ -59,6 +58,7 @@
     error,
     extensions,
     osutil,
+    pycompat,
     util,
 )
 
@@ -122,7 +122,7 @@
         modules.append(__version__)
     except ImportError:
         pass
-    files = [sys.executable]
+    files = [pycompat.sysexecutable]
     for m in modules:
         try:
             files.append(inspect.getabsfile(m))
diff -r 11739d0ee458 -r 681d2b64c896 mercurial/commands.py
--- a/mercurial/commands.py	Tue Dec 20 00:02:24 2016 +0530
+++ b/mercurial/commands.py	Tue Dec 20 00:20:07 2016 +0530
@@ -1889,7 +1889,7 @@
 
     # Python
     fm.write('pythonexe', _("checking Python executable (%s)\n"),
-             sys.executable)
+             pycompat.sysexecutable)
     fm.write('pythonver', _("checking Python version (%s)\n"),
              ("%d.%d.%d" % sys.version_info[:3]))
     fm.write('pythonlib', _("checking Python lib (%s)...\n"),
diff -r 11739d0ee458 -r 681d2b64c896 mercurial/i18n.py
--- a/mercurial/i18n.py	Tue Dec 20 00:02:24 2016 +0530
+++ b/mercurial/i18n.py	Tue Dec 20 00:20:07 2016 +0530
@@ -19,7 +19,7 @@
 
 # modelled after templater.templatepath:
 if getattr(sys, 'frozen', None) is not None:
-    module = sys.executable
+    module = pycompat.sysexecutable
 else:
     module = __file__
 
diff -r 11739d0ee458 -r 681d2b64c896 mercurial/sslutil.py
--- a/mercurial/sslutil.py	Tue Dec 20 00:02:24 2016 +0530
+++ b/mercurial/sslutil.py	Tue Dec 20 00:20:07 2016 +0530
@@ -669,9 +669,9 @@
       cacerts file
     """
     if (pycompat.sysplatform != 'darwin' or
-                        util.mainfrozen() or not sys.executable):
+                        util.mainfrozen() or not pycompat.sysexecutable):
         return False
-    exe = os.path.realpath(sys.executable).lower()
+    exe = os.path.realpath(pycompat.sysexecutable).lower()
     return (exe.startswith('/usr/bin/python') or
             exe.startswith('/system/library/frameworks/python.framework/'))
 
diff -r 11739d0ee458 -r 681d2b64c896 mercurial/util.py
--- a/mercurial/util.py	Tue Dec 20 00:02:24 2016 +0530
+++ b/mercurial/util.py	Tue Dec 20 00:20:07 2016 +0530
@@ -931,7 +931,7 @@
 # the location of data files matching the source code
 if mainfrozen() and getattr(sys, 'frozen', None) != 'macosx_app':
     # executable version (py2exe) doesn't support __file__
-    datapath = os.path.dirname(sys.executable)
+    datapath = os.path.dirname(pycompat.sysexecutable)
 else:
     datapath = os.path.dirname(__file__)
 
@@ -957,7 +957,7 @@
                 # Env variable set by py2app
                 _sethgexecutable(encoding.environ['EXECUTABLEPATH'])
             else:
-                _sethgexecutable(sys.executable)
+                _sethgexecutable(pycompat.sysexecutable)
         elif os.path.basename(getattr(mainmod, '__file__', '')) == 'hg':
             _sethgexecutable(mainmod.__file__)
         else:
@@ -2299,7 +2299,7 @@
             # Env variable set by py2app
             return [encoding.environ['EXECUTABLEPATH']]
         else:
-            return [sys.executable]
+            return [pycompat.sysexecutable]
     return gethgcmd()
 
 def rundetached(args, condfn):


More information about the Mercurial-devel mailing list