14

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.

maraujop
  • 4,472
  • 2
  • 36
  • 40

1 Answers1

6

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()
micromoses
  • 6,747
  • 2
  • 20
  • 29