简体   繁体   English

调试python gtk3应用程序

[英]Debugging python gtk3 application

I'm writing a text editor in python and gtk3 and I keep getting vague warnings from somewhere within glib when I close a window: 我正在用python和gtk3编写文本编辑器,当我关闭窗口时,我总是从glib中的某个地方收到模糊的警告:

/usr/lib/python2.7/dist-packages/gi/types.py:47: Warning: invalid (NULL) pointer instance
  return info.invoke(*args, **kwargs)

How can I debug this? 我该如何调试? I tried running it in gdb, hoping I might be able to learn something from a breakpoint at g_logv, but the warnings appear without triggering the breakpoint. 我尝试在gdb中运行它,希望我可以从g_logv的断点学到一些东西,但是警告显示时没有触发断点。 I can't easily replace the log handler either because of https://bugzilla.gnome.org/show_bug.cgi?id=670507 . 由于https://bugzilla.gnome.org/show_bug.cgi?id=670507,我无法轻松替换日志处理程序。

I've even tried altering the python file referenced in the message so that it always prints a python backtrace at that point, but it has to do it whether the error occurs or not and it gets called on every gobject method call, so it's difficult to interpret the results, and it still doesn't tell me anything about which pointer is null. 我什至尝试更改消息中引用的python文件,以便它始终在该点打印python backtrace,但无论是否发生错误都必须这样做,并且每次gobject方法调用都会调用它,因此很难解释结果,它仍然没有告诉我有关哪个指针为空的任何信息。

If you want to use gdb, just run your script with the G_DEBUG environment variable set to "fatal-warnings" ( G_DEBUG=fatal-warnings ./your-script.py ). 如果要使用gdb,只需在G_DEBUG环境变量设置为“ fatal-warnings”( G_DEBUG=fatal-warnings ./your-script.py )的情况下运行脚本。 There is documentation in the Running GLib Applications section of the GLib manual. GLib手册的“正在运行的GLib应用程序”部分中有文档。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM