changeset 30669:10b17ed9b591

py3: replace sys.executable with pycompat.sysexecutable sys.executable returns unicodes on Python 3. This patch replaces occurences of sys.executable with pycompat.sysexecutable.
author Pulkit Goyal <7895pulkit@gmail.com>
date Tue, 20 Dec 2016 00:20:07 +0530
parents 3fcaf0f660ce
children 07fa9765b821
files mercurial/chgserver.py mercurial/commands.py mercurial/i18n.py mercurial/sslutil.py mercurial/util.py
diffstat 5 files changed, 9 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- 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))
--- 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"),
--- 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__
 
--- 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/'))
 
--- 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):