想想这个场景:
我调试我的 Django 项目并单步执行代码(进出)。调试器有时会进入 Django 库或其他外部库。
有谁知道如何防止调试器输入外部代码?或者至少是一个“大”步骤,让调试器返回到项目代码?
最佳答案
Does anyone know how to prevent the debugger from entering external code?
是的,德米特里·特罗菲莫夫 knows ;
(...) add modules you don't want to trace to the dict
DONT_TRACE
in<pycharm-distr>/helpers/pydev/pydevd.py
That is a hacky solution (...)
如果你希望这个功能不那么hacky,你可以通过访问问题对其进行投票
PY-9101 Implement "Do not step into the classes" option for Python debugger
使用pdb的人可能有兴趣知道pdb中有这样的特性;
从 Python 3.1 开始,Pdb
类有一个名为 skip
的新参数-
class pdb.Pdb(completekey='tab', stdin=None, stdout=None, skip=None, nosigint=False)
The skip argument, if given, must be an iterable of glob-style module name patterns. The debugger will not step into frames that originate in a module that matches one of these patterns. 1
1 Whether a frame is considered to originate in a certain module is determined by the
__name__
in the frame globals.
文档中给出的示例显示了如何跳过 Django 的包 -
import pdb; pdb.Pdb(skip=['django.*']).set_trace()
关于python - 使用pycharm调试,如何在不进入django库的情况下进入项目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15164565/