From 983161186594c6fd7a0a97c76018dccd24e11a63 Mon Sep 17 00:00:00 2001 From: Benjamin Peterson Date: Sun, 24 Oct 2010 02:57:31 +0000 Subject: Merged revisions 85814 via svnmerge from svn+ssh://pythondev@svn.python.org/python/branches/py3k ........ r85814 | benjamin.peterson | 2010-10-23 21:52:05 -0500 (Sat, 23 Oct 2010) | 1 line remove broken code accounting an offset the size of the line #10186 ........ --- Lib/test/test_traceback.py | 6 ++++++ Misc/NEWS | 3 +++ Python/pythonrun.c | 2 -- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/Lib/test/test_traceback.py b/Lib/test/test_traceback.py index 17413db..d39322f 100644 --- a/Lib/test/test_traceback.py +++ b/Lib/test/test_traceback.py @@ -296,6 +296,12 @@ class BaseExceptionReportingTests: self.assertTrue('inner_raise() # Marker' in blocks[2]) self.check_zero_div(blocks[2]) + def test_syntax_error_offset_at_eol(self): + # See #10186. + def e(): + raise SyntaxError('', ('', 0, 5, 'hello')) + msg = self.get_report(e).splitlines() + self.assertEqual(msg[-2], " ^") class PyExcReportingTests(BaseExceptionReportingTests, unittest.TestCase): diff --git a/Misc/NEWS b/Misc/NEWS index e2c424c..c505aee 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -12,6 +12,9 @@ Core and Builtins - Issue #10077: Fix logging of site module errors at startup. +- Issue #10186: Fix the SyntaxError caret when the offset is equal to the length + of the offending line. + - Issue #9713, #10114: Parser functions (eg. PyParser_ASTFromFile) expects filenames encoded to the filesystem encoding with surrogateescape error handler (to support undecodable bytes), instead of UTF-8 in strict mode. diff --git a/Python/pythonrun.c b/Python/pythonrun.c index 98cad37..10a1d50 100644 --- a/Python/pythonrun.c +++ b/Python/pythonrun.c @@ -1299,8 +1299,6 @@ print_error_text(PyObject *f, int offset, const char *text) { char *nl; if (offset >= 0) { - if (offset > 0 && offset == (int)strlen(text)) - offset--; for (;;) { nl = strchr(text, '\n'); if (nl == NULL || nl-text >= offset) -- cgit v0.12