[Python-checkins] r85814 - in python/branches/py3k: Lib/test/test_traceback.py Misc/NEWS Python/pythonrun.c

benjamin.peterson python-checkins at python.org
Sun Oct 24 04:52:06 CEST 2010


Author: benjamin.peterson
Date: Sun Oct 24 04:52:05 2010
New Revision: 85814

Log:
remove broken code accounting an offset the size of the line #10186

Modified:
   python/branches/py3k/Lib/test/test_traceback.py
   python/branches/py3k/Misc/NEWS
   python/branches/py3k/Python/pythonrun.c

Modified: python/branches/py3k/Lib/test/test_traceback.py
==============================================================================
--- python/branches/py3k/Lib/test/test_traceback.py	(original)
+++ python/branches/py3k/Lib/test/test_traceback.py	Sun Oct 24 04:52:05 2010
@@ -289,6 +289,12 @@
         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):

Modified: python/branches/py3k/Misc/NEWS
==============================================================================
--- python/branches/py3k/Misc/NEWS	(original)
+++ python/branches/py3k/Misc/NEWS	Sun Oct 24 04:52:05 2010
@@ -10,6 +10,9 @@
 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

Modified: python/branches/py3k/Python/pythonrun.c
==============================================================================
--- python/branches/py3k/Python/pythonrun.c	(original)
+++ python/branches/py3k/Python/pythonrun.c	Sun Oct 24 04:52:05 2010
@@ -1344,8 +1344,6 @@
 {
     char *nl;
     if (offset >= 0) {
-        if (offset > 0 && offset == (int)strlen(text))
-            offset--;
         for (;;) {
             nl = strchr(text, '\n');
             if (nl == NULL || nl-text >= offset)


More information about the Python-checkins mailing list