mercurial/pycompat.py
changeset 32186 76f9a0009b4b
parent 31942 bc0579a25f82
child 32450 548478efc46c
--- a/mercurial/pycompat.py	Mon May 01 17:23:48 2017 +0900
+++ b/mercurial/pycompat.py	Thu Apr 20 22:16:12 2017 +0900
@@ -164,6 +164,10 @@
             return s
         return s.decode(u'latin-1')
 
+    def raisewithtb(exc, tb):
+        """Raise exception with the given traceback"""
+        raise exc.with_traceback(tb)
+
     def _wrapattrfunc(f):
         @functools.wraps(f)
         def w(object, name, *args):
@@ -224,6 +228,10 @@
     sysbytes = identity
     sysstr = identity
 
+    # this can't be parsed on Python 3
+    exec('def raisewithtb(exc, tb):\n'
+         '    raise exc, None, tb\n')
+
     # Partial backport from os.py in Python 3, which only accepts bytes.
     # In Python 2, our paths should only ever be bytes, a unicode path
     # indicates a bug.