[Zope3-checkins] SVN: Zope3/branches/3.3/src/zope/exceptions/
Cosmetic bugfix for the exception formatter: it used to
double the newlines
Marius Gedminas
marius at pov.lt
Thu Jun 1 06:54:19 EDT 2006
Log message for revision 68429:
Cosmetic bugfix for the exception formatter: it used to double the newlines
in exception messages (e.g. SyntaxError exceptions)
Merged from trunk with
svn merge -r 68412:68413 svn+ssh://svn.zope.org/repos/main/Zope3/trunk .
Changed:
U Zope3/branches/3.3/src/zope/exceptions/exceptionformatter.py
U Zope3/branches/3.3/src/zope/exceptions/tests/test_exceptionformatter.py
-=-
Modified: Zope3/branches/3.3/src/zope/exceptions/exceptionformatter.py
===================================================================
--- Zope3/branches/3.3/src/zope/exceptions/exceptionformatter.py 2006-06-01 10:40:02 UTC (rev 68428)
+++ Zope3/branches/3.3/src/zope/exceptions/exceptionformatter.py 2006-06-01 10:54:18 UTC (rev 68429)
@@ -158,8 +158,8 @@
return self.line_sep.join(result)
def formatExceptionOnly(self, etype, value):
- return self.line_sep.join(
- traceback.format_exception_only(etype, value))
+ result = ''.join(traceback.format_exception_only(etype, value))
+ return result.replace('\n', self.line_sep)
def formatLastLine(self, exc_line):
return self.escape(exc_line)
Modified: Zope3/branches/3.3/src/zope/exceptions/tests/test_exceptionformatter.py
===================================================================
--- Zope3/branches/3.3/src/zope/exceptions/tests/test_exceptionformatter.py 2006-06-01 10:40:02 UTC (rev 68428)
+++ Zope3/branches/3.3/src/zope/exceptions/tests/test_exceptionformatter.py 2006-06-01 10:54:18 UTC (rev 68429)
@@ -143,6 +143,22 @@
self.assert_(s.find('<') >= 0, s)
self.assert_(s.find('>') >= 0, s)
+ def testMultilineException(self):
+ try:
+ exec 'syntax error'
+ except:
+ s = tb()
+ # Traceback (most recent call last):
+ # Module zope.exceptions.tests.test_exceptionformatter, line ??, in testMultilineException
+ # exec \'syntax error\'
+ # File "<string>", line 1
+ # syntax error
+ # ^
+ # SyntaxError: unexpected EOF while parsing
+ self.assertEquals(s.splitlines()[-3:],
+ [' syntax error',
+ ' ^',
+ 'SyntaxError: unexpected EOF while parsing'])
def test_suite():
More information about the Zope3-Checkins
mailing list