[pypy-commit] pypy py3.5: Fix traceback.print_exception() when exc.offset == 0
rlamy
pypy.commits at gmail.com
Tue Nov 21 13:38:19 EST 2017
Author: Ronan Lamy <ronan.lamy at gmail.com>
Branch: py3.5
Changeset: r93117:e37a09d8450a
Date: 2017-11-21 18:38 +0000
http://bitbucket.org/pypy/pypy/changeset/e37a09d8450a/
Log: Fix traceback.print_exception() when exc.offset == 0
diff --git a/lib-python/3/traceback.py b/lib-python/3/traceback.py
--- a/lib-python/3/traceback.py
+++ b/lib-python/3/traceback.py
@@ -544,8 +544,8 @@
yield ' {}\n'.format(badline.strip())
if offset is not None:
caretspace = badline.rstrip('\n')
- offset = min(len(caretspace), offset) - 1
- caretspace = caretspace[:offset].lstrip()
+ # bug in CPython: the case offset==0 is mishandled
+ caretspace = caretspace[:offset].lstrip()[:-1]
# non-space whitespace (likes tabs) must be kept for alignment
caretspace = ((c.isspace() and c or ' ') for c in caretspace)
yield ' {}^\n'.format(''.join(caretspace))
More information about the pypy-commit
mailing list