pythonpdbipdb

ipdb stops showing prompt text after carriage return


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

EDIT 2022-3-31

EDIT 2022-3-31 (2.0)

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.


Solution

  • 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()