Is it possible to get all lines of a continuation line in a traceback?
Example:
#! /usr/bin/env python
def function_with_long_name(foo, bar):
raise Exception('problem?'开发者_JS百科)
function_with_long_name('very_important_value',
'meaningless_value')
Output:
$ ./test.py
Traceback (most recent call last):
File "./test.py", line 5, in <module>
'meaningless_value')
File "./test.py", line 3, in function_with_long_name
raise Exception('problem?')
Exception: problem?
Note that it prints only the last line of the continuation line.
I would like to have all lines of the continuation line, something like this:
$ ./test.py
Traceback (most recent call last):
File "./test.py", line 5, in <module>
function_with_long_name('very_important_value',
'meaningless_value')
File "./test.py", line 3, in function_with_long_name
raise Exception('problem?')
Exception: problem?
Is this possible?
I have looked at the traceback
module, but the values it returns are already truncated.
Example:
#! /usr/bin/env python
import traceback
def function_with_long_name(foo, bar):
print traceback.extract_stack()
function_with_long_name('very_important_value',
'meaningless_value')
Output:
$ ./test.py
[('./test.py', 6, '<module>', "'meaningless_value')"), ('./test.py', 4, 'function_with_long_name', 'print traceback.extract_stack()')]
Someone appears to have just opened Python issue 12458 about this. Suggest you follow along there.
精彩评论