New submission from thewtex <m...@mmmccormick.com>:

On Python 2.6.2, and possibly other versions, in the traceback module,
format_exception_only does not behave correctly when printout out a
SyntaxError.  An extra newline is inserted before the carot.  E.g.

 38         exceptionType, exceptionValue, exceptionTraceback =
sys.exc_info()                        
 39         sys.stderr.write("Exception:\n")
 40         ex = traceback.format_exception_only(exceptionType,
exceptionValue)
 41         sys.stderr.write(repr(ex))
 42         for line in ex:
 43             sys.stderr.write(line) 

yields, e.g.
Exception:
['  File "/home/matt/apps/posac/source/posac/posac_main.py", line 12\n',
'    def run()\n', '            \n^\n', 'SyntaxError: invalid syntax\n']
 File "/home/matt/apps/posac/source/posac/posac_main.py", line 12
    def run()
            
^
SyntaxError: invalid syntax

When it should be:
Exception:
['  File "/home/matt/apps/posac/source/posac/posac_main.py", line 12\n',
'    def run()\n', '             ^\n', 'SyntaxError: invalid syntax\n']
 File "/home/matt/apps/posac/source/posac/posac_main.py", line 12
    def run()
             ^
SyntaxError: invalid syntax


Attached is a patch.  This patch has been tested on gentoo linux.

----------
messages: 92966
nosy: thewtex
severity: normal
status: open
title: traceback.format_exception_only does not return SyntaxError carot 
correctly
type: behavior
versions: Python 2.6

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue6962>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to