inducer / pudb

Full-screen console debugger for Python
https://documen.tician.de/pudb/
Other
2.94k stars 226 forks source link

Error reported when exiting iPython and returning to UI on Mac OS X #601

Open knoxsp opened 1 year ago

knoxsp commented 1 year ago

Describe the bug I enter iPython terminal from the debugger UI by pressing !. When I exit (ctrl+d) it returns to the UI. Upon the second exit from iPython, the following error is shown, which I can then dismiss:

The full traceback and some other information can be found below. Please report this information, along with details on what you were      < OK          
doing at the time the exception occurred, at: https://github.com/inducer/pudb/issues                                                       < Save        
                                                                                                                                             traceback   
python version: 3.11.2 (main, Feb 16 2023, 02:55:59) [Clang 14.0.0 (clang-1400.0.29.202)]                                                                
pudb version: 2022.1.3                                                                                                                                   
urwid version: 2.1.2                                                                                                                                     
Traceback (most recent call last):                                                                                                                       
  File "/Users/stephenknox/venv/lib/python3.11/site-packages/pudb/debugger.py", line 2704, in event_loop                                                 
    toplevel.keypress(self.size, k)                                                                                                                      
  File "/Users/stephenknox/venv/lib/python3.11/site-packages/pudb/ui_tools.py", line 124, in keypress                                                    1
    return handler(self, size, key)                                                                                                                      50
           ^^^^^^^^^^^^^^^^^^^^^^^^                                                                                                                      
  File "/Users/stephenknox/venv/lib/python3.11/site-packages/pudb/debugger.py", line 2071, in run_cmdline                                                
    return run_external_cmdline(w, size, key)                                                                                                            
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^                                                                                                            
  File "/Users/stephenknox/venv/lib/python3.11/site-packages/pudb/debugger.py", line 2063, in run_external_cmdline                                       
    runner(curframe.f_globals, curframe.f_locals)                                                                                                        
  File "/Users/stephenknox/venv/lib/python3.11/site-packages/pudb/shell.py", line 244, in run_ipython_shell                                              
    return run_ipython_shell_v11(globals, locals)                                                                                                        
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^                                                                                                        
  File "/Users/stephenknox/venv/lib/python3.11/site-packages/pudb/shell.py", line 232, in run_ipython_shell_v11                                          
    shell.mainloop(*args)                                                                                                                                
  File "/Users/stephenknox/venv/lib/python3.11/site-packages/IPython/terminal/interactiveshell.py", line 900, in mainloop                                
    self.restore_term_title()                                                                                                                            
  File "/Users/stephenknox/venv/lib/python3.11/site-packages/IPython/terminal/interactiveshell.py", line 602, in restore_term_title                      
    restore_term_title()                                                                                                                                 
  File "/Users/stephenknox/venv/lib/python3.11/site-packages/IPython/utils/terminal.py", line 115, in restore_term_title                                 
    _restore_term_title()                                                                                                                                
  File "/Users/stephenknox/venv/lib/python3.11/site-packages/IPython/utils/terminal.py", line 83, in _restore_term_title_xterm                           
    assert _xterm_term_title_saved                                                                                                                       
AssertionError

To Reproduce Steps to reproduce the behavior:

  1. Go to a breakpoint at any part of the code
  2. Enter the terminal with '!'
  3. exit terminal (ctrl+d)
  4. Re-enter terminal (!)
  5. Exit terminal again (ctrl + d)

Expected behavior Returns to the debugger without error

Screenshots

Additional context Add any other context about the problem here.

Versions

What version of pudb? What version of Python? System: Mac OS X Ventura 13.3.1 python version: 3.11.2 pudb version: 2022.1.3 iPython version: 8.12.0

inducer commented 1 year ago

What terminal emulator are you using?

knoxsp commented 1 year ago

I'm using iTerm2

inducer commented 1 year ago

I can reproduce this. Unfortunately, I'm not entirely sure what to do. The problem seems to be global state kept in IPython. Maybe someone could talk to them. In the meantime, ptipython may serve as a way to avoid this problem.