如何在开发过程中调试升华插件

编程入门 行业动态 更新时间:2024-10-27 13:22:56
本文介绍了如何在开发过程中调试升华插件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 我想使用pdb调试我的插件,但是它不起作用。我收到这些错误

追溯(最近的最后一次呼叫):文件./sublime_plugin.py,行362,in run_ 文件./useIt.py,第14行,在$ self $。中为$。文件./useIt.py,第14行,运行 for self.view.sel()中的区域:文件.\bdb.py,第46行,在trace_dispatch 文件.\bdb。 py,第65行,在dispatch_line bdb.BdbQuit

有没有人理念?还是其他一些调试升级插件的方法?

解决方案

问题是 sys .stdin 没有附加到任何通常。但是,如果从控制台启动SublimeText2,则 sys.stdin 可以正常工作:

  • 在Mac上,通过在终端中输入完整路径,将资源包中的可执行文件定位到启动应用程序:

    / Applications / Sublime\ Text\ 2.app/Contents/MacOS/Sublime\ Text\ 2

  • 在Windows上,从Windows控制台启动应用程序:

    C:\Program Files\ Sublime Text 2\sublime_text.exe

    临时,我没有Windows Sublime Text 2安装,所以这个命令行是基于一个快速的Google

该应用程序有一个控制台;但 sys.stdout 仍然重定向到内置的SublimeText 2控制台。您想使用正确的 stdout 启动调试器,该控制台仍然连接到控制台。而不是 import pdb; pdb.set_trace(),使用:

import pdb,sys; pdb.Pdb(stdout = sys .__ stdout __)。set_trace()

原始控制台 stdout 保存在 sys .__ stdout __ 中,并将其传递给 pdb.Pdb()你得到一个功能完整的 pdb 会话。

I want to debug my plugin with pdb but it doesn't work. I get these errors

Traceback (most recent call last): File "./sublime_plugin.py", line 362, in run_ File "./useIt.py", line 14, in run for region in self.view.sel(): File "./useIt.py", line 14, in run for region in self.view.sel(): File ".\bdb.py", line 46, in trace_dispatch File ".\bdb.py", line 65, in dispatch_line bdb.BdbQuit

Has anyone an idea? Or some other way to debug a sublime plugin?

解决方案

The problem is that sys.stdin is not attached to anything normally. But, sys.stdin does work if you start SublimeText2 from a console:

  • On Mac, start the application by locating the executable in the resource bundle by entering the full path in the Terminal:

    /Applications/Sublime\ Text\ 2.app/Contents/MacOS/Sublime\ Text\ 2

  • On Windows, start the application from the Windows Console:

    "C:\Program Files\Sublime Text 2\sublime_text.exe"

    provisional, I have no Windows Sublime Text 2 install so this command line is based on a quick Google

Now the application has a console; but sys.stdout is still redirected to the built-in SublimeText 2 console. You want to start your debugger with the correct stdout, the one still connected to your console. Instead of import pdb; pdb.set_trace(), use:

import pdb, sys; pdb.Pdb(stdout=sys.__stdout__).set_trace()

The original console stdout is saved in sys.__stdout__ and by passing that to pdb.Pdb() you get a fully functional pdb session.

更多推荐

如何在开发过程中调试升华插件

本文发布于:2023-07-22 04:03:04,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1183979.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:过程中   插件   如何在

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!