継続行のすべての行をトレースバックで取得することは可能ですか?
例:
#! /usr/bin/env python
def function_with_long_name(foo, bar):
raise Exception('problem?')
function_with_long_name('very_important_value',
'meaningless_value')
出力:
$ ./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?
継続行の最後の行のみを出力することに注意してください。
次のような継続行のすべての行が必要です。
$ ./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?
これは可能ですか?
モジュールを見てきましたtraceback
が、返される値はすでに切り捨てられています。
例:
#! /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')
出力:
$ ./test.py
[('./test.py', 6, '<module>', "'meaningless_value')"), ('./test.py', 4, 'function_with_long_name', 'print traceback.extract_stack()')]