用pycharm调试,如何步入项目,无需进入django库 [英] Debugging with pycharm, how to step into project, without entering django libraries

查看:25
本文介绍了用pycharm调试,如何步入项目,无需进入django库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

想想这个场景:

我调试我的 Django 项目并逐步执行代码(进出).调试器有时会进入 Django 库或其他外部库.

I debug my Django project and I step through the code (in and out). The debugger sometimes enters Django libraries or other external libraries.

有谁知道如何防止调试器输入外部代码?或者至少是大"一步让调试器回到项目代码?

Does anyone know how to prevent the debugger from entering external code? Or at least a 'big' step out to get the debugger back to the project code?

推荐答案

有谁知道如何防止调试器输入外部代码?

Does anyone know how to prevent the debugger from entering external code?

是的,Dmitry Trofimov 知道

Yes, Dmitry Trofimov knows;

(...) 在 <pycharm-distr>/helpers/pydev/pydevd.py 中将不想跟踪的模块添加到字典 DONT_TRACE
这是一个 hacky 解决方案 (...)

(...) 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,您可以通过访问 issue 对其进行投票
PY-9101 为 Python 调试器实现不要步入类"选项

If you want this feature to be less hacky you can vote on it by visiting issue
PY-9101 Implement "Do not step into the classes" option for Python debugger

使用 pdb 的人可能有兴趣知道 pdb 中有这样的功能;

Those using pdb might be interested to know there is such a feature in pdb;

从 Python 3.1 开始,Pdb 类有一个名为 跳过 -

Starting with Python 3.1, Pdb class has a new argument called skip -

class pdb.Pdb(completekey='tab', stdin=None, stdout=None, skip=None, nosigint=False)

skip 参数,如果给定,必须是一个可迭代的 glob 样式模块名称模式.调试器不会进入源自的帧在与这些模式之一匹配的模块中.1

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 是否认为帧来自在某个模块中是由框架全局变量中的 __name__ 确定.

1 Whether a frame is considered to originate in a certain module is determined by the __name__ in the frame globals.

文档中给出的示例显示了如何跳过 Django 的包 -

The example given in the docs shows how to skip Django's packages -

导入pdb;pdb.Pdb(skip=['django.*']).set_trace()

这篇关于用pycharm调试,如何步入项目,无需进入django库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆