mirror of
https://github.com/python/cpython.git
synced 2025-08-30 21:48:47 +00:00
Issue #17825: Cursor ^ is correctly positioned for SyntaxError and IndentationError.
This commit is contained in:
commit
45e124e26d
3 changed files with 21 additions and 7 deletions
|
@ -224,11 +224,12 @@ def _format_exception_only_iter(etype, value):
|
|||
if badline is not None:
|
||||
yield ' {}\n'.format(badline.strip())
|
||||
if offset is not None:
|
||||
caretspace = badline.rstrip('\n')[:offset].lstrip()
|
||||
caretspace = badline.rstrip('\n')
|
||||
offset = min(len(caretspace), offset) - 1
|
||||
caretspace = caretspace[:offset].lstrip()
|
||||
# non-space whitespace (likes tabs) must be kept for alignment
|
||||
caretspace = ((c.isspace() and c or ' ') for c in caretspace)
|
||||
# only three spaces to account for offset1 == pos 0
|
||||
yield ' {}^\n'.format(''.join(caretspace))
|
||||
yield ' {}^\n'.format(''.join(caretspace))
|
||||
msg = value.msg or "<no detail available>"
|
||||
yield "{}: {}\n".format(stype, msg)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue