Python pdb 无法正确破坏文件?
我希望我可以提供一个使用标准库代码发生的简单示例案例,但不幸的是,它仅在使用我们的内部库之一时发生,而该内部库又构建在 sql alchemy 之上。
基本上,问题在于这个 break
命令:
(Pdb) print sqlalchemy.engine.base.__file__
/prod/eggs/SQLAlchemy-0.5.5-py2.5.egg/sqlalchemy/engine/base.py
(Pdb) break /prod/eggs/SQLAlchemy-0.5.5-py2.5.egg/sqlalchemy/engine/base.py:946
似乎被 pdb
完全忽略了。就像,即使我肯定,代码仍然被命中(既因为我可以看到日志消息,又因为我使用sys.settrace
来检查哪些文件被命中),pdb
只是没有破坏那里。
我怀疑,不知何故,鸡蛋的使用使 pdb
混淆了正在使用的文件(如果我使用非鸡蛋库,例如 pickle,我无法重现该错误
; 一切正常)。
这是黑暗中的一枪,但以前有人遇到过这种情况吗?
I wish I could provide a simple sample case that occurs using standard library code, but unfortunately it only happens when using one of our in-house libraries that in turn is built on top of sql alchemy.
Basically, the problem is that this break
command:
(Pdb) print sqlalchemy.engine.base.__file__
/prod/eggs/SQLAlchemy-0.5.5-py2.5.egg/sqlalchemy/engine/base.py
(Pdb) break /prod/eggs/SQLAlchemy-0.5.5-py2.5.egg/sqlalchemy/engine/base.py:946
Is just being totally ignored, it seems, by pdb
. As in, even though I am positive the code is being hit (both because I can see log messages, and because I've used sys.settrace
to check which lines in which files are being hit), pdb
is just not breaking there.
I suspect that somehow the use of an egg is confusing pdb
as to what files are being used (I can't reproduce the error if I use a non-egg'ed library, like pickle
; there everything works fine).
It's a shot in the dark, but has anyone come across this before?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我想知道是否有一个旧的 .pyc 由于权限混乱而无法删除。删除 python 路径中的所有 .pycs,看看是否有帮助。
这篇博文可能与您的问题有关。
I wonder if somehow there's an old .pyc that can't be deleted because of permissions being messed up. Nuke all of the .pycs in your python-path, and see if that helps.
This blog post might be related to your trouble.
我不认为这是 setuptools 引起的另一个问题?我问是因为我注意到该路径中的“.egg”......
I don't suppose this is yet another problem caused by setuptools? I ask because I notice the ".egg" in that path...
正在运行什么版本的 python?我在 python 2.7.3 上观察到类似的行为。奇怪的是,我在 ipython 0.12.1 上没有看到相同的行为。
在 python 2.7.3 中,调试器和堆栈跟踪获取错误发生异常的点。
在ipython 0.12.1中,调试器和堆栈跟踪获取异常发生的点是正确的,但是一旦发生异常,程序就会退出,这使得事后调试变得困难。
What version of python are running? I observe similar behavior on python 2.7.3. Curiously, I do not see the same behavior on ipython 0.12.1.
In python 2.7.3, the debugger and the stack trace get the point where an exception occurred wrong.
In ipython 0.12.1, the debugger and the stack trace get the point where the exception occurs is correct, but once the exception occurs, then the program exits, which makes post mortem debugging difficult.