版本信息-Python 2.7.15; Python 3.6.5 ; ipdb == 0.11
我无法在以下代码中的调试器(weak var delegate: MyDelegate?
或err
)内的Python 3中访问捕获的异常pdb
。 ipdb
也不可用。
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