This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author thewtex
Recipients thewtex
Date 2009-09-21.22:26:50
SpamBayes Score 3.3682306e-06
Marked as misclassified No
Message-id <1253572012.9.0.846902756749.issue6962@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2009-09-21 22:26:52thewtexsetrecipients: + thewtex
2009-09-21 22:26:52thewtexsetmessageid: <1253572012.9.0.846902756749.issue6962@psf.upfronthosting.co.za>
2009-09-21 22:26:51thewtexlinkissue6962 messages
2009-09-21 22:26:51thewtexcreate