Python pdb 无法正确破坏文件?

发布于 2024-08-08 03:39:12 字数 618 浏览 4 评论 0原文

我希望我可以提供一个使用标准库代码发生的简单示例案例,但不幸的是,它仅在使用我们的内部库之一时发生,而该内部库又构建在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

戏舞 2024-08-15 03:39:12

我想知道是否有一个旧的 .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.

久夏青 2024-08-15 03:39:12

我不认为这是 setuptools 引起的另一个问题?我问是因为我注意到该路径中的“.egg”......

I don't suppose this is yet another problem caused by setuptools? I ask because I notice the ".egg" in that path...

马蹄踏│碎落叶 2024-08-15 03:39:12

正在运行什么版本的 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文