changeset 31843:526e4597cca5

py3: add pycompat.unicode and add it to importer On python 3, builtins.unicode does not exist.
author Pulkit Goyal <7895pulkit@gmail.com>
date Fri, 07 Apr 2017 23:35:51 +0530
parents c130d092042a
children 478999e8281d
files mercurial/__init__.py mercurial/pycompat.py
diffstat 2 files changed, 4 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/__init__.py	Fri Apr 07 16:00:44 2017 +0530
+++ b/mercurial/__init__.py	Fri Apr 07 23:35:51 2017 +0530
@@ -283,7 +283,8 @@
                     continue
                 r, c = t.start
                 l = (b'; from mercurial.pycompat import '
-                     b'delattr, getattr, hasattr, setattr, xrange, open\n')
+                     b'delattr, getattr, hasattr, setattr, xrange, '
+                     b'open, unicode\n')
                 for u in tokenize.tokenize(io.BytesIO(l).readline):
                     if u.type in (tokenize.ENCODING, token.ENDMARKER):
                         continue
@@ -323,7 +324,7 @@
     # ``replacetoken`` or any mechanism that changes semantics of module
     # loading is changed. Otherwise cached bytecode may get loaded without
     # the new transformation mechanisms applied.
-    BYTECODEHEADER = b'HG\x00\x09'
+    BYTECODEHEADER = b'HG\x00\x0a'
 
     class hgloader(importlib.machinery.SourceFileLoader):
         """Custom module loader that transforms source code.
--- a/mercurial/pycompat.py	Fri Apr 07 16:00:44 2017 +0530
+++ b/mercurial/pycompat.py	Fri Apr 07 23:35:51 2017 +0530
@@ -174,6 +174,7 @@
     hasattr = _wrapattrfunc(builtins.hasattr)
     setattr = _wrapattrfunc(builtins.setattr)
     xrange = builtins.range
+    unicode = str
 
     def open(name, mode='r', buffering=-1):
         return builtins.open(name, sysstr(mode), buffering)