pdb / ipdb吞噬了Python 3中调试器中的异常

时间:2019-04-04 11:21:56

标签: python-3.x python-2.7 python-3.6 pdb ipdb

版本信息-Python 2.7.15; Python 3.6.5 ; ipdb == 0.11

我无法在以下代码中的调试器(weak var delegate: MyDelegate? err)内的Python 3中访问捕获的异常pdbipdb也不可用。

locals

输出:

Python 2:

try:
    raise ValueError("I am ValueError")
except ValueError as err:
    print("err={}".format(err))
    print("err" in locals())
    import pdb; pdb.set_trace() # not able to acess err in Python 3

Python 3:

err=I am ValueError
True
--Return--
> test_script.py(6)<module>()->None
-> import pdb; pdb.set_trace() # not able to acess err in Python 3
(Pdb) print("err" in locals())
True

这仅在调试器内部发生,因为err=I am ValueError True --Return-- > test_script.py(6)<module>()->None -> import pdb; pdb.set_trace() # not able to acess err in Python 3 (Pdb) print("err" in locals()) False <------------------ BUG?? (Pdb) 在退出(或从不进入)调试器后已在err中神奇地还原。

locals

0 个答案:

没有答案