##// END OF EJS Templates
pycompat: extract helper to raise exception with traceback...
Yuya Nishihara -
r32186:76f9a000 default
parent child Browse files
Show More
@@ -1005,7 +1005,7 b' class bundlepart(object):'
1005 # backup exception data for later
1005 # backup exception data for later
1006 ui.debug('bundle2-input-stream-interrupt: encoding exception %s'
1006 ui.debug('bundle2-input-stream-interrupt: encoding exception %s'
1007 % exc)
1007 % exc)
1008 exc_info = sys.exc_info()
1008 tb = sys.exc_info()[2]
1009 msg = 'unexpected error: %s' % exc
1009 msg = 'unexpected error: %s' % exc
1010 interpart = bundlepart('error:abort', [('message', msg)],
1010 interpart = bundlepart('error:abort', [('message', msg)],
1011 mandatory=False)
1011 mandatory=False)
@@ -1016,10 +1016,7 b' class bundlepart(object):'
1016 outdebug(ui, 'closing payload chunk')
1016 outdebug(ui, 'closing payload chunk')
1017 # abort current part payload
1017 # abort current part payload
1018 yield _pack(_fpayloadsize, 0)
1018 yield _pack(_fpayloadsize, 0)
1019 if pycompat.ispy3:
1019 pycompat.raisewithtb(exc, tb)
1020 raise exc_info[0](exc_info[1]).with_traceback(exc_info[2])
1021 else:
1022 exec("""raise exc_info[0], exc_info[1], exc_info[2]""")
1023 # end of payload
1020 # end of payload
1024 outdebug(ui, 'closing payload chunk')
1021 outdebug(ui, 'closing payload chunk')
1025 yield _pack(_fpayloadsize, 0)
1022 yield _pack(_fpayloadsize, 0)
@@ -164,6 +164,10 b' if ispy3:'
164 return s
164 return s
165 return s.decode(u'latin-1')
165 return s.decode(u'latin-1')
166
166
167 def raisewithtb(exc, tb):
168 """Raise exception with the given traceback"""
169 raise exc.with_traceback(tb)
170
167 def _wrapattrfunc(f):
171 def _wrapattrfunc(f):
168 @functools.wraps(f)
172 @functools.wraps(f)
169 def w(object, name, *args):
173 def w(object, name, *args):
@@ -224,6 +228,10 b' else:'
224 sysbytes = identity
228 sysbytes = identity
225 sysstr = identity
229 sysstr = identity
226
230
231 # this can't be parsed on Python 3
232 exec('def raisewithtb(exc, tb):\n'
233 ' raise exc, None, tb\n')
234
227 # Partial backport from os.py in Python 3, which only accepts bytes.
235 # Partial backport from os.py in Python 3, which only accepts bytes.
228 # In Python 2, our paths should only ever be bytes, a unicode path
236 # In Python 2, our paths should only ever be bytes, a unicode path
229 # indicates a bug.
237 # indicates a bug.
General Comments 0
You need to be logged in to leave comments. Login now