Skip to content

Commit 9831611

Browse files
committed
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 python#10186 ........
1 parent feca46c commit 9831611

3 files changed

Lines changed: 9 additions & 2 deletions

File tree

‎Lib/test/test_traceback.py‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,12 @@ def outer_raise():
296296
self.assertTrue('inner_raise() # Marker' in blocks[2])
297297
self.check_zero_div(blocks[2])
298298

299+
def test_syntax_error_offset_at_eol(self):
300+
# See #10186.
301+
def e():
302+
raise SyntaxError('', ('', 0, 5, 'hello'))
303+
msg = self.get_report(e).splitlines()
304+
self.assertEqual(msg[-2], " ^")
299305

300306

301307
class PyExcReportingTests(BaseExceptionReportingTests, unittest.TestCase):

‎Misc/NEWS‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ Core and Builtins
1212

1313
- Issue #10077: Fix logging of site module errors at startup.
1414

15+
- Issue #10186: Fix the SyntaxError caret when the offset is equal to the length
16+
of the offending line.
17+
1518
- Issue #9713, #10114: Parser functions (eg. PyParser_ASTFromFile) expects
1619
filenames encoded to the filesystem encoding with surrogateescape error
1720
handler (to support undecodable bytes), instead of UTF-8 in strict mode.

‎Python/pythonrun.c‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1299,8 +1299,6 @@ print_error_text(PyObject *f, int offset, const char *text)
12991299
{
13001300
char *nl;
13011301
if (offset >= 0) {
1302-
if (offset > 0 && offset == (int)strlen(text))
1303-
offset--;
13041302
for (;;) {
13051303
nl = strchr(text, '\n');
13061304
if (nl == NULL || nl-text >= offset)

0 commit comments

Comments
 (0)