summaryrefslogtreecommitdiffstats
path: root/Misc
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2020-05-15 02:22:48 (GMT)
committerGitHub <noreply@github.com>2020-05-15 02:22:48 (GMT)
commit15bc9ab301d73f20bff47a12ef05326feb40f797 (patch)
treee29afe19a6ce7aaa5b7f1ea3639810080ea6d2d5 /Misc
parent1aa8767baf498a920f0461d1088772a12dcb4d20 (diff)
downloadcpython-15bc9ab301d73f20bff47a12ef05326feb40f797.zip
cpython-15bc9ab301d73f20bff47a12ef05326feb40f797.tar.gz
cpython-15bc9ab301d73f20bff47a12ef05326feb40f797.tar.bz2
bpo-40612: Fix SyntaxError edge cases in traceback formatting (GH-20072)
This fixes both the traceback.py module and the C code for formatting syntax errors (in Python/pythonrun.c). They now both consistently do the following: - Suppress caret if it points left of text - Allow caret pointing just past end of line - If caret points past end of line, clip to *just* past end of line The syntax error formatting code in traceback.py was mostly rewritten; small, subtle changes were applied to the C code in pythonrun.c. There's still a difference when the text contains embedded newlines. Neither handles these very well, and I don't think the case occurs in practice. Automerge-Triggered-By: @gvanrossum
Diffstat (limited to 'Misc')
-rw-r--r--Misc/NEWS.d/next/Library/2020-05-13-10-23-29.bpo-40612.gOIreM.rst2
1 files changed, 2 insertions, 0 deletions
diff --git a/Misc/NEWS.d/next/Library/2020-05-13-10-23-29.bpo-40612.gOIreM.rst b/Misc/NEWS.d/next/Library/2020-05-13-10-23-29.bpo-40612.gOIreM.rst
new file mode 100644
index 0000000..32cc807
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2020-05-13-10-23-29.bpo-40612.gOIreM.rst
@@ -0,0 +1,2 @@
+Fix edge cases in SyntaxError formatting. If the offset is <= 0, no caret is printed.
+If the offset is > line length, the caret is printed pointing just after the last character.