[ python-Bugs-1447885 ] traceback.format_exception_only() and SyntaxError

SourceForge.net noreply at sourceforge.net
Sat Mar 11 14:51:04 CET 2006


Bugs item #1447885, was opened at 2006-03-11 14:46
Message generated for change (Comment added) made by remyblank
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1447885&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Library
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Remy Blank (remyblank)
Assigned to: Nobody/Anonymous (nobody)
Summary: traceback.format_exception_only() and SyntaxError

Initial Comment:
There is a special case in
traceback.format_exception_only() for SyntaxError so
that the location of the syntax error is printed.
Unfortunately, the test is written so that it only
works with SyntaxError, but not for children of
SyntaxError, e.g. IndentationError.

OTOH, the interpreter prints the correct output if the
exception is allowed to terminate the program.

I have attached a test case that shows the difference
in output. With the current traceback.py module, the
output is different:

joe at pat py $ ./testSyntaxError.py
Traceback (most recent call last):
  File "./testSyntaxError.py", line 7, in ?
    import SyntaxErr
IndentationError: expected an indented block
(SyntaxErr.py, line 2)

joe at pat py $ ./testSyntaxError.py raise
Traceback (most recent call last):
  File "./testSyntaxError.py", line 7, in ?
    import SyntaxErr
  File "/home/joe/tmp/py/SyntaxErr.py", line 2
    class OtherClass:
        ^
IndentationError: expected an indented block

There's a second file that is needed for the test case,
I'll attach it as well.

----------------------------------------------------------------------

>Comment By: Remy Blank (remyblank)
Date: 2006-03-11 14:51

Message:
Logged In: YES 
user_id=568100

This patch makes both the output of the interpreter and the
output generated by format_exception_only() identical.

----------------------------------------------------------------------

Comment By: Remy Blank (remyblank)
Date: 2006-03-11 14:47

Message:
Logged In: YES 
user_id=568100

This file generates the IndentationError.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1447885&group_id=5470


More information about the Python-bugs-list mailing list