##// END OF EJS Templates
py3: use pycompat.fsencode() to convert __file__ to bytes...
Pulkit Goyal -
r31074:2912b069 default
parent child Browse files
Show More
@@ -692,7 +692,7 b' def debugextensions(ui, **opts):'
692 fm = ui.formatter('debugextensions', opts)
692 fm = ui.formatter('debugextensions', opts)
693 for extname, extmod in sorted(exts, key=operator.itemgetter(0)):
693 for extname, extmod in sorted(exts, key=operator.itemgetter(0)):
694 isinternal = extensions.ismoduleinternal(extmod)
694 isinternal = extensions.ismoduleinternal(extmod)
695 extsource = extmod.__file__
695 extsource = pycompat.fsencode(extmod.__file__)
696 if isinternal:
696 if isinternal:
697 exttestedwith = [] # never expose magic string to users
697 exttestedwith = [] # never expose magic string to users
698 else:
698 else:
@@ -970,7 +970,7 b' def debuginstall(ui, **opts):'
970 fm.write('hgmodulepolicy', _("checking module policy (%s)\n"),
970 fm.write('hgmodulepolicy', _("checking module policy (%s)\n"),
971 policy.policy)
971 policy.policy)
972 fm.write('hgmodules', _("checking installed modules (%s)...\n"),
972 fm.write('hgmodules', _("checking installed modules (%s)...\n"),
973 os.path.dirname(__file__))
973 os.path.dirname(pycompat.fsencode(__file__)))
974
974
975 err = None
975 err = None
976 try:
976 try:
@@ -362,7 +362,8 b' def _disabledpaths(strip_init=False):'
362 '''find paths of disabled extensions. returns a dict of {name: path}
362 '''find paths of disabled extensions. returns a dict of {name: path}
363 removes /__init__.py from packages if strip_init is True'''
363 removes /__init__.py from packages if strip_init is True'''
364 import hgext
364 import hgext
365 extpath = os.path.dirname(os.path.abspath(hgext.__file__))
365 extpath = os.path.dirname(
366 os.path.abspath(pycompat.fsencode(hgext.__file__)))
366 try: # might not be a filesystem path
367 try: # might not be a filesystem path
367 files = os.listdir(extpath)
368 files = os.listdir(extpath)
368 except OSError:
369 except OSError:
@@ -21,7 +21,7 b' from . import ('
21 if getattr(sys, 'frozen', None) is not None:
21 if getattr(sys, 'frozen', None) is not None:
22 module = pycompat.sysexecutable
22 module = pycompat.sysexecutable
23 else:
23 else:
24 module = __file__
24 module = pycompat.fsencode(__file__)
25
25
26 try:
26 try:
27 unicode
27 unicode
@@ -720,7 +720,8 b' def _defaultcacerts(ui):'
720 # to load the system CA store. If we're running on Apple Python, use this
720 # to load the system CA store. If we're running on Apple Python, use this
721 # trick.
721 # trick.
722 if _plainapplepython():
722 if _plainapplepython():
723 dummycert = os.path.join(os.path.dirname(__file__), 'dummycert.pem')
723 dummycert = os.path.join(
724 os.path.dirname(pycompat.fsencode(__file__)), 'dummycert.pem')
724 if os.path.exists(dummycert):
725 if os.path.exists(dummycert):
725 return dummycert
726 return dummycert
726
727
@@ -724,7 +724,7 b' def simplifypath(path):'
724
724
725 if path in _pathcache:
725 if path in _pathcache:
726 return _pathcache[path]
726 return _pathcache[path]
727 hgpath = encoding.__file__.rsplit(os.sep, 2)[0]
727 hgpath = pycompat.fsencode(encoding.__file__).rsplit(os.sep, 2)[0]
728 for p in [hgpath] + sys.path:
728 for p in [hgpath] + sys.path:
729 prefix = p + os.sep
729 prefix = p + os.sep
730 if path.startswith(prefix):
730 if path.startswith(prefix):
@@ -955,10 +955,7 b" if mainfrozen() and getattr(sys, 'frozen"
955 # executable version (py2exe) doesn't support __file__
955 # executable version (py2exe) doesn't support __file__
956 datapath = os.path.dirname(pycompat.sysexecutable)
956 datapath = os.path.dirname(pycompat.sysexecutable)
957 else:
957 else:
958 datapath = os.path.dirname(__file__)
958 datapath = os.path.dirname(pycompat.fsencode(__file__))
959
960 if not isinstance(datapath, bytes):
961 datapath = pycompat.fsencode(datapath)
962
959
963 i18n.setdatapath(datapath)
960 i18n.setdatapath(datapath)
964
961
@@ -980,8 +977,9 b' def hgexecutable():'
980 _sethgexecutable(encoding.environ['EXECUTABLEPATH'])
977 _sethgexecutable(encoding.environ['EXECUTABLEPATH'])
981 else:
978 else:
982 _sethgexecutable(pycompat.sysexecutable)
979 _sethgexecutable(pycompat.sysexecutable)
983 elif os.path.basename(getattr(mainmod, '__file__', '')) == 'hg':
980 elif (os.path.basename(
984 _sethgexecutable(mainmod.__file__)
981 pycompat.fsencode(getattr(mainmod, '__file__', ''))) == 'hg'):
982 _sethgexecutable(pycompat.fsencode(mainmod.__file__))
985 else:
983 else:
986 exe = findexe('hg') or os.path.basename(sys.argv[0])
984 exe = findexe('hg') or os.path.basename(sys.argv[0])
987 _sethgexecutable(exe)
985 _sethgexecutable(exe)
General Comments 0
You need to be logged in to leave comments. Login now