bzm3r
bzm3r

Reputation: 4596

Attempting to debug terminal applications made with Python+Blessed using ipdb breaks IPython?

I am using the Blessed library to build a simple terminal application.

My application builds upon the following simple example for a dumb editor: https://github.com/jquast/blessed/blob/master/bin/editor.py

Warning: the following steps will break your IPython, and I don't know how to fix it!

For the purposes of this question, I'll just use editor.py. Let's make a couple of changes to allow debugging:

1) import ipdb

2) put in ipdb.set_trace() on line 224

Run editor.py now: python editor.py. The following error should be produced:

Traceback (most recent call last):
  File "editor.py", line 14, in <module>
    from manager import Manager
  File "/home/abcd/python_scripts/editor.py", line 25, in <module>
    import ipdb
  File "/usr/local/lib/python2.7/dist-packages/ipdb/__init__.py", line 7, in <module>
    from ipdb.__main__ import set_trace, post_mortem, pm, run, runcall, runeval, launch_ipdb_on_exception
  File "/usr/local/lib/python2.7/dist-packages/ipdb/__main__.py", line 47, in <module>
    ipapp.initialize([])
  File "<decorator-gen-110>", line 2, in initialize
  File "/usr/lib/python2.7/dist-packages/IPython/config/application.py", line 92, in catch_config_error
    return method(app, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/IPython/terminal/ipapp.py", line 332, in initialize
    self.init_shell()
  File "/usr/lib/python2.7/dist-packages/IPython/terminal/ipapp.py", line 348, in init_shell
    ipython_dir=self.ipython_dir, user_ns=self.user_ns)
  File "/usr/lib/python2.7/dist-packages/IPython/config/configurable.py", line 354, in instance
    inst = cls(*args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/IPython/terminal/interactiveshell.py", line 328, in __init__
    **kwargs
  File "/usr/lib/python2.7/dist-packages/IPython/core/interactiveshell.py", line 483, in __init__
    self.init_readline()
  File "/usr/lib/python2.7/dist-packages/IPython/core/interactiveshell.py", line 1843, in init_readline
    self.readline_startup_hook = readline.set_startup_hook
AttributeError: 'module' object has no attribute 'set_startup_hook'

If you suspect this is an IPython bug, please report it at:
    https://github.com/ipython/ipython/issues
or send an email to the mailing list at [email protected]

You can print a more detailed traceback right now with "%tb", or use "%debug"
to interactively debug it.

Extra-detailed tracebacks for bug-reporting purposes can be enabled via:
    c.Application.verbose_crash=True

Now, whenever one runs IPython by executing the ipython command, this error will be produced:

Traceback (most recent call last):
  File "/usr/bin/ipython", line 5, in <module>
    start_ipython()
  File "/usr/lib/python2.7/dist-packages/IPython/__init__.py", line 120, in start_ipython
    return launch_new_instance(argv=argv, **kwargs)
  File "/usr/lib/python2.7/dist-packages/IPython/config/application.py", line 564, in launch_instance
    app.initialize(argv)
  File "<decorator-gen-110>", line 2, in initialize
  File "/usr/lib/python2.7/dist-packages/IPython/config/application.py", line 92, in catch_config_error
    return method(app, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/IPython/terminal/ipapp.py", line 332, in initialize
    self.init_shell()
  File "/usr/lib/python2.7/dist-packages/IPython/terminal/ipapp.py", line 348, in init_shell
    ipython_dir=self.ipython_dir, user_ns=self.user_ns)
  File "/usr/lib/python2.7/dist-packages/IPython/config/configurable.py", line 354, in instance
    inst = cls(*args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/IPython/terminal/interactiveshell.py", line 328, in __init__
    **kwargs
  File "/usr/lib/python2.7/dist-packages/IPython/core/interactiveshell.py", line 483, in __init__
    self.init_readline()
  File "/usr/lib/python2.7/dist-packages/IPython/core/interactiveshell.py", line 1843, in init_readline
    self.readline_startup_hook = readline.set_startup_hook
AttributeError: 'module' object has no attribute 'set_startup_hook'

If you suspect this is an IPython bug, please report it at:
    https://github.com/ipython/ipython/issues
or send an email to the mailing list at [email protected]

You can print a more detailed traceback right now with "%tb", or use "%debug"
to interactively debug it.

Extra-detailed tracebacks for bug-reporting purposes can be enabled via:
    c.Application.verbose_crash=True

So, IPython seems to be globally broken. I have gotten this issue on both Cygwin and Ubuntu.

What's going wrong?

Upvotes: 1

Views: 487

Answers (0)

Related Questions