##// END OF EJS Templates
py3: add pycompat.unicode and add it to importer...
Pulkit Goyal -
r31843:526e4597 default
parent child Browse files
Show More
@@ -283,7 +283,8 b' if sys.version_info[0] >= 3:'
283 continue
283 continue
284 r, c = t.start
284 r, c = t.start
285 l = (b'; from mercurial.pycompat import '
285 l = (b'; from mercurial.pycompat import '
286 b'delattr, getattr, hasattr, setattr, xrange, open\n')
286 b'delattr, getattr, hasattr, setattr, xrange, '
287 b'open, unicode\n')
287 for u in tokenize.tokenize(io.BytesIO(l).readline):
288 for u in tokenize.tokenize(io.BytesIO(l).readline):
288 if u.type in (tokenize.ENCODING, token.ENDMARKER):
289 if u.type in (tokenize.ENCODING, token.ENDMARKER):
289 continue
290 continue
@@ -323,7 +324,7 b' if sys.version_info[0] >= 3:'
323 # ``replacetoken`` or any mechanism that changes semantics of module
324 # ``replacetoken`` or any mechanism that changes semantics of module
324 # loading is changed. Otherwise cached bytecode may get loaded without
325 # loading is changed. Otherwise cached bytecode may get loaded without
325 # the new transformation mechanisms applied.
326 # the new transformation mechanisms applied.
326 BYTECODEHEADER = b'HG\x00\x09'
327 BYTECODEHEADER = b'HG\x00\x0a'
327
328
328 class hgloader(importlib.machinery.SourceFileLoader):
329 class hgloader(importlib.machinery.SourceFileLoader):
329 """Custom module loader that transforms source code.
330 """Custom module loader that transforms source code.
@@ -174,6 +174,7 b' if ispy3:'
174 hasattr = _wrapattrfunc(builtins.hasattr)
174 hasattr = _wrapattrfunc(builtins.hasattr)
175 setattr = _wrapattrfunc(builtins.setattr)
175 setattr = _wrapattrfunc(builtins.setattr)
176 xrange = builtins.range
176 xrange = builtins.range
177 unicode = str
177
178
178 def open(name, mode='r', buffering=-1):
179 def open(name, mode='r', buffering=-1):
179 return builtins.open(name, sysstr(mode), buffering)
180 return builtins.open(name, sysstr(mode), buffering)
General Comments 0
You need to be logged in to leave comments. Login now