[ENH] Provides command line tool for pydumpling#16
Conversation
code format
|
我更新了dev分支,现在在保存dump文件的同时会保留异常的type和value,所以可以直接使用Python内置的print方法来打印错误堆栈了,可以检查下这样是否符合我们的预期 |
|
因为目前没有CI,所以可以修改完成后,运行sh test.sh看一下测试结果是否通过 |
|
你本地测试的python版本是什么呢,我在3.10/3.11测试没有复现 |
|
我们还可以修改一下README,增加一下命令行工具的用法说明和例子 |
python 版本是 3.11.5(windows) 和 3.11.8 (linux), 两个平台都测试过,出现的问题是一样的。 我单独调用 from pydumpling import dump_current_traceback
from inspect import currentframe
def inner():
a = 1
b = "2"
dump_current_traceback("test.dump")
c = str(a) + b
def outer():
d = 4
inner()
outer()执行的结果为: RuntimeWarning: Unexpected error: list index out of range when dumping traceback
warnings.warn(err_msg, RuntimeWarning)
README 我明天修改一下,同步上去 |
|
分支都是一样的。以下是我重新测试的结果: 还有一点,我稍微修改了以下 列表 |
|
我更新了我的dev分支,可以拉取一下最新的,试一下还会不会报错。然后我们用内置函数来打印错误栈信息吧,像这样: from traceback import print_tb, print_exception
def print_traceback_and_except(dumpling_result):
exc_tb = dumpling_result["traceback"]
except_extra = dumpling_result.get("exc_extra")
exc_type = except_extra["exc_type"] if except_extra else None
exc_value = except_extra["exc_value"] if except_extra else None
if exc_type and exc_value:
print_exception(exc_type, exc_value, exc_tb)
else:
print_tb(exc_tb) |
|
现在测试应该没有问题,我先合并了,感谢贡献 |





Ref: #12
Provides command line tools