[Python-checkins] r85904 - in python/branches/py3k: Lib/test/test_traceback.py Python/pythonrun.c
benjamin.peterson
python-checkins at python.org
Fri Oct 29 05:28:15 CEST 2010
Author: benjamin.peterson
Date: Fri Oct 29 05:28:14 2010
New Revision: 85904
Log:
decrement offset when it points to a newline (#10186 followup)
Modified:
python/branches/py3k/Lib/test/test_traceback.py
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 Fri Oct 29 05:28:14 2010
@@ -295,6 +295,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/py3k/Python/pythonrun.c
==============================================================================
--- python/branches/py3k/Python/pythonrun.c (original)
+++ python/branches/py3k/Python/pythonrun.c Fri Oct 29 05:28:14 2010
@@ -1344,6 +1344,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)
@@ -1363,7 +1365,7 @@
if (offset == -1)
return;
PyFile_WriteString(" ", f);
- while (--offset)
+ while (--offset > 0)
PyFile_WriteString(" ", f);
PyFile_WriteString("^\n", f);
}
More information about the Python-checkins
mailing list