ipdb 在回车后停止显示提示文本

发布于 2025-01-16 09:07:42 字数 1127 浏览 7 评论 0原文

最近,当使用ipdb.set_trace(context=20)设置断点时,我可以看到我第一次输入的命令,点击回车后,下次我在我的ipdb中写入指令或命令时提示未显示。当我按回车键时,它会执行它并在前面的行中显示它。

直到最近才发生这种情况。我使用的是 mac,带有 iterm、最新的 ipdb 和 pytest。

编辑 2022-3-29

  • 我一直在尝试使用 shell 设置,断开 ozsh、抗原插件,以查看它是否相关,但似乎没有影响。

  • 我也尝试过使用终端,而不是 iterm。

  • 以下是我所描述内容的录音: 输入图像描述这里

编辑 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.

  • Here is a recording of what I'm describing:
    enter image description here

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 技术交流群。

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

发布评论

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

评论(1

似梦非梦 2025-01-23 09:07:42

这看起来不像 ipdb 中的错误(也不是 IPython 中的错误,它也会重现)。问题出在 freezegun 和 prompt-toolkit 之间,其中 IPython (以及 ipdb)依靠。我希望他们会接受此 PR,但在此之前此行为可以通过以下方式解决:使用 extend_ignore_list 参数将 prompt_toolkit 添加到忽略列表,如下所示:

import ipdb
import freezegun

freezegun.configure(extend_ignore_list=['prompt_toolkit'])

@freezegun.freeze_time("2022-3-12")
def test_prompt_ipdb():
    ipdb.set_trace()

test_prompt_ipdb()

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 the extend_ignore_list argument, like so:

import ipdb
import freezegun

freezegun.configure(extend_ignore_list=['prompt_toolkit'])

@freezegun.freeze_time("2022-3-12")
def test_prompt_ipdb():
    ipdb.set_trace()

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