summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2010-10-24 02:52:05 (GMT)
committerBenjamin Peterson <benjamin@python.org>2010-10-24 02:52:05 (GMT)
commit503d6c5ae90c4427b236cff8b4f12051a8e72129 (patch)
tree3d753193202cf4dbe5bb4daa36c7072629186250
parent8451c4b6e044f83efc2298a79af58c3e56d946a2 (diff)
downloadcpython-503d6c5ae90c4427b236cff8b4f12051a8e72129.zip
cpython-503d6c5ae90c4427b236cff8b4f12051a8e72129.tar.gz
cpython-503d6c5ae90c4427b236cff8b4f12051a8e72129.tar.bz2
remove broken code accounting an offset the size of the line #10186
-rw-r--r--Lib/test/test_traceback.py6
-rw-r--r--Misc/NEWS3
-rw-r--r--Python/pythonrun.c2
3 files changed, 9 insertions, 2 deletions
diff --git a/Lib/test/test_traceback.py b/Lib/test/test_traceback.py
index 11bdf58..e4ae4ab 100644
--- a/Lib/test/test_traceback.py
+++ b/Lib/test/test_traceback.py
@@ -289,6 +289,12 @@ class BaseExceptionReportingTests:
self.assertIn('inner_raise() # Marker', 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 4c7dc4b..98bc24f 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -10,6 +10,9 @@ What's New in Python 3.2 Beta 1?
Core and Builtins
-----------------
+- Issue #10186: Fix the SyntaxError caret when the offset is equal to the length
+ of the offending line.
+
- Issue #6011: sysconfig and distutils.sysconfig use the surrogateescape error
handler to parse the Makefile file. Avoid a UnicodeDecodeError if the source
code directory name contains a non-ASCII character and the locale encoding is
diff --git a/Python/pythonrun.c b/Python/pythonrun.c
index f755d11..cf8f7bf 100644
--- a/Python/pythonrun.c
+++ b/Python/pythonrun.c
@@ -1344,8 +1344,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)