[Python-checkins] r85906 - in python/branches/release31-maint: Lib/test/test_traceback.py Python/pythonrun.c

benjamin.peterson python-checkins at python.org
Fri Oct 29 06:02:30 CEST 2010


Author: benjamin.peterson
Date: Fri Oct 29 06:02:30 2010
New Revision: 85906

Log:
Merged revisions 85817,85904 via svnmerge from 
svn+ssh://pythondev@svn.python.org/python/branches/py3k

........
  r85817 | benjamin.peterson | 2010-10-23 22:41:46 -0500 (Sat, 23 Oct 2010) | 1 line
  
  tighten loop
........
  r85904 | benjamin.peterson | 2010-10-28 22:28:14 -0500 (Thu, 28 Oct 2010) | 1 line
  
  decrement offset when it points to a newline (#10186 followup)
........


Modified:
   python/branches/release31-maint/   (props changed)
   python/branches/release31-maint/Lib/test/test_traceback.py
   python/branches/release31-maint/Python/pythonrun.c

Modified: python/branches/release31-maint/Lib/test/test_traceback.py
==============================================================================
--- python/branches/release31-maint/Lib/test/test_traceback.py	(original)
+++ python/branches/release31-maint/Lib/test/test_traceback.py	Fri Oct 29 06:02:30 2010
@@ -302,6 +302,10 @@
             raise SyntaxError('', ('', 0, 5, 'hello'))
         msg = self.get_report(e).splitlines()
         self.assertEqual(msg[-2], "        ^")
+        def e():
+            exec("x = 5 | 4 |")
+        msg = self.get_report(e).splitlines()
+        self.assertEqual(msg[-2], '              ^')
 
 
 class PyExcReportingTests(BaseExceptionReportingTests, unittest.TestCase):

Modified: python/branches/release31-maint/Python/pythonrun.c
==============================================================================
--- python/branches/release31-maint/Python/pythonrun.c	(original)
+++ python/branches/release31-maint/Python/pythonrun.c	Fri Oct 29 06:02:30 2010
@@ -1299,6 +1299,8 @@
 {
     char *nl;
     if (offset >= 0) {
+        if (offset > 0 && offset == strlen(text) && text[offset - 1] == '\n')
+            offset--;
         for (;;) {
             nl = strchr(text, '\n');
             if (nl == NULL || nl-text >= offset)
@@ -1318,11 +1320,8 @@
     if (offset == -1)
         return;
     PyFile_WriteString("    ", f);
-    offset--;
-    while (offset > 0) {
+    while (--offset > 0)
         PyFile_WriteString(" ", f);
-        offset--;
-    }
     PyFile_WriteString("^\n", f);
 }
 


More information about the Python-checkins mailing list