comparison mercurial/util.py @ 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 e995f00a9e9a
children d9e5b0aeeb90
comparison
equal deleted inserted replaced
30668:3fcaf0f660ce 30669:10b17ed9b591
929 imp.is_frozen(u"__main__")) # tools/freeze 929 imp.is_frozen(u"__main__")) # tools/freeze
930 930
931 # the location of data files matching the source code 931 # the location of data files matching the source code
932 if mainfrozen() and getattr(sys, 'frozen', None) != 'macosx_app': 932 if mainfrozen() and getattr(sys, 'frozen', None) != 'macosx_app':
933 # executable version (py2exe) doesn't support __file__ 933 # executable version (py2exe) doesn't support __file__
934 datapath = os.path.dirname(sys.executable) 934 datapath = os.path.dirname(pycompat.sysexecutable)
935 else: 935 else:
936 datapath = os.path.dirname(__file__) 936 datapath = os.path.dirname(__file__)
937 937
938 if not isinstance(datapath, bytes): 938 if not isinstance(datapath, bytes):
939 datapath = pycompat.fsencode(datapath) 939 datapath = pycompat.fsencode(datapath)
955 elif mainfrozen(): 955 elif mainfrozen():
956 if getattr(sys, 'frozen', None) == 'macosx_app': 956 if getattr(sys, 'frozen', None) == 'macosx_app':
957 # Env variable set by py2app 957 # Env variable set by py2app
958 _sethgexecutable(encoding.environ['EXECUTABLEPATH']) 958 _sethgexecutable(encoding.environ['EXECUTABLEPATH'])
959 else: 959 else:
960 _sethgexecutable(sys.executable) 960 _sethgexecutable(pycompat.sysexecutable)
961 elif os.path.basename(getattr(mainmod, '__file__', '')) == 'hg': 961 elif os.path.basename(getattr(mainmod, '__file__', '')) == 'hg':
962 _sethgexecutable(mainmod.__file__) 962 _sethgexecutable(mainmod.__file__)
963 else: 963 else:
964 exe = findexe('hg') or os.path.basename(sys.argv[0]) 964 exe = findexe('hg') or os.path.basename(sys.argv[0])
965 _sethgexecutable(exe) 965 _sethgexecutable(exe)
2297 if mainfrozen(): 2297 if mainfrozen():
2298 if getattr(sys, 'frozen', None) == 'macosx_app': 2298 if getattr(sys, 'frozen', None) == 'macosx_app':
2299 # Env variable set by py2app 2299 # Env variable set by py2app
2300 return [encoding.environ['EXECUTABLEPATH']] 2300 return [encoding.environ['EXECUTABLEPATH']]
2301 else: 2301 else:
2302 return [sys.executable] 2302 return [pycompat.sysexecutable]
2303 return gethgcmd() 2303 return gethgcmd()
2304 2304
2305 def rundetached(args, condfn): 2305 def rundetached(args, condfn):
2306 """Execute the argument list in a detached process. 2306 """Execute the argument list in a detached process.
2307 2307