Revision 2372
Added by Aaron Marcuse-Kubitza over 12 years ago
lib/exc.py | ||
---|---|---|
52 | 52 |
Exception.__init__(self, msg) |
53 | 53 |
|
54 | 54 |
def str_(e, first_line_only=False): |
55 |
msg = u''.join(traceback.format_exception_only(type(e), e)).rstrip() |
|
55 |
if isinstance(e, SyntaxError): |
|
56 |
# format_exception_only() provides special formatting for SyntaxErrors. |
|
57 |
msg = u''.join(traceback.format_exception_only(type(e), e)) |
|
58 |
else: |
|
59 |
# Avoid traceback exception-formatting functions because they escape |
|
60 |
# non-ASCII characters with \x, causing exception parsers to read an |
|
61 |
# incorrect, escaped value. |
|
62 |
msg = util.class_name(e)+': '+e.args[0] |
|
63 |
|
|
56 | 64 |
if first_line_only: msg = msg.partition('\n')[0] |
57 |
return msg |
|
65 |
return msg.rstrip()
|
|
58 | 66 |
|
59 | 67 |
def print_ex(e, emph=True, detail=True, plain=False): |
60 | 68 |
if plain: |
Also available in: Unified diff
exc.py: str_(): Avoid traceback exception-formatting functions when possible because they escape non-ASCII characters