ipdb 在回车后停止显示提示文本
最近,当使用ipdb.set_trace(context=20)
设置断点时,我可以看到我第一次输入的命令,点击回车后,下次我在我的ipdb中写入指令或命令时提示未显示。当我按回车键时,它会执行它并在前面的行中显示它。
直到最近才发生这种情况。我使用的是 mac,带有 iterm、最新的 ipdb 和 pytest。
编辑 2022-3-29
编辑 2022-3-31
- 我意识到这只发生在我的一个项目中
- 无论哪种类型,出现异常后提示都会消失,否则它总是工作正常。
- 在异常提示开始失败之后,但有时在我编写了一个简单的 python 程序以相同的设置运行后,它并不在第一个命令中
- ,但它没有发生,所以还有其他一些事情与这个
编辑 2022- 3-31 (2.0)
- 花了一些时间玩这个之后,我发现这只发生在一些测试中,那些用 freezegun 装饰的测试
我正在使用 freezegun 1.2.1 和 pytest 6.2.5.当我运行此代码时,如果我执行 print 几次,光标就会消失。这是我能想到的最基本的复制测试。
import ipdb from freezegun import freeze_time @freeze_time("2022-3-12") def test_prompt_ipdb(): ipdb.set_trace() test_prompt_ipdb()
我现在相信这是这两个之一的错误,很可能是 freezegun 做了一些奇特的事情。
Recently when setting up a breakpoint using ipdb.set_trace(context=20)
I can see the command I'm inputing the first time, after hitting return, next time I write an instruction or command in my ipdb prompt is not showing. When I hit enter it executes it and shows it in the previous lines.
This wasn't happening until very recently. I'm using mac, with iterm, latest ipdb and pytest.
EDIT 2022-3-29
I've been trying to play with the shell settings, disconnect ozsh, antigen plugins, to see it was related, but doesn't seem to affect.
I've also tried with terminal, instead of iterm.
EDIT 2022-3-31
- I've realized this only happens with one of my projects
- The prompt disappears after an exception occurs no matter which type, otherwise it always works fine.
- After the exception prompt starts failing, but sometimes it's not in the first command after
- I've written a simple python program to run with the same setup and it doesn't happen, so there's something else messing with this
EDIT 2022-3-31 (2.0)
- After spending some time playing with this, I discovered this was only happening in some tests, the ones decorated with freezegun
I'm using freezegun 1.2.1 and pytest 6.2.5. When I run this code if I execute print a couple times, cursor disappears. This is the most basic reproduction test I've been able to come up with.
import ipdb from freezegun import freeze_time @freeze_time("2022-3-12") def test_prompt_ipdb(): ipdb.set_trace() test_prompt_ipdb()
I now believe this a bug in one of these two, most likely freezegun doing something fancy.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这看起来不像 ipdb 中的错误(也不是 IPython 中的错误,它也会重现)。问题出在 freezegun 和 prompt-toolkit 之间,其中 IPython (以及 ipdb)依靠。我希望他们会接受此 PR,但在此之前此行为可以通过以下方式解决:使用
extend_ignore_list
参数将prompt_toolkit
添加到忽略列表,如下所示:This doesn't seem like a bug in ipdb (nor in IPython for that matter, with which this reproduces as well). The problem is between freezegun and prompt-toolkit, which IPython (and consequently ipdb) rely on. I'm hoping they will accept this PR, but until then this behavior can be resolved by adding
prompt_toolkit
to the ignore-list using theextend_ignore_list
argument, like so: