inducer/pudb — Issue #30: Problems with pudb and IPython 0.12
Author: asmeurer
Created: 2012-01-06 04:46:55+00:00
State: open

I got this both in IPython 0.12 and the git master of IPython. If I type ! to go to IPython, I get the following. The first few frames up to _print_Pow are my debugging stack.

```py
ERROR: An unexpected error occurred while tokenizing input
The following traceback may be corrupted or invalid
The error message is: ('EOF in multi-line statement', (101, 0))
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
/Users/aaronmeurer/Documents/Python/sympy/sympy/ in ()
----> 1 pprint(g)

/Users/aaronmeurer/Documents/Python/sympy/sympy/sympy/printing/pretty/pretty.pyc in pretty_print(expr, **settings)
1402
1403 """
-> 1404 print pretty(expr, **settings)
1405
1406 pprint = pretty_print

/Users/aaronmeurer/Documents/Python/sympy/sympy/sympy/printing/pretty/pretty.pyc in pretty(expr, **settings)
1373
1374 try:
-> 1375 return pp.doprint(expr)
1376 finally:
1377 pretty_use_unicode(uflag)

/Users/aaronmeurer/Documents/Python/sympy/sympy/sympy/printing/pretty/pretty.pyc in doprint(self, expr)
40
41 def doprint(self, expr):
---> 42 return self._print(expr).render(**self._settings)
43
44 # empty op so _print(stringPict) returns the same

/Users/aaronmeurer/Documents/Python/sympy/sympy/sympy/printing/printer.pyc in _print(self, expr, *args)
250 printmethod = '_print_' + cls.__name__
251 if hasattr(self, printmethod):
--> 252 return getattr(self, printmethod)(expr, *args)
253
254 # Unknown object, fall back to the emptyPrinter.

/Users/aaronmeurer/Documents/Python/sympy/sympy/sympy/printing/pretty/pretty.pyc in _print_Mul(self, product)
1014 b[i] = prettyForm(*self._print(b[i]).parens())
1015 else:
-> 1016 b[i] = self._print(b[i])
1017
1018 # Construct a pretty form

/Users/aaronmeurer/Documents/Python/sympy/sympy/sympy/printing/printer.pyc in _print(self, expr, *args)
250 printmethod = '_print_' + cls.__name__
251 if hasattr(self, printmethod):
--> 252 return getattr(self, printmethod)(expr, *args)
253
254 # Unknown object, fall back to the emptyPrinter.

/Users/aaronmeurer/Documents/Python/sympy/sympy/sympy/printing/pretty/pretty.pyc in _print_Pow(self, power)
1028 # square roots, other roots or n-th roots

1029 #test for fraction 1/n or power x**-1

-> 1030 if power.is_commutative:
1031 if (isinstance(power.exp, C.Rational) and power.exp.p==1 and power.exp.q !=1) or \
1032 ( isinstance(power.exp, C.Pow) and

/Users/aaronmeurer/Documents/Python/sympy/sympy/sympy/printing/pretty/pretty.pyc in _print_Pow(self, power)
1028 # square roots, other roots or n-th roots

1029 #test for fraction 1/n or power x**-1

-> 1030 if power.is_commutative:
1031 if (isinstance(power.exp, C.Rational) and power.exp.p==1 and power.exp.q !=1) or \
1032 ( isinstance(power.exp, C.Pow) and

/sw/lib/python2.7/bdb.pyc in trace_dispatch(self, frame, event, arg)
46 return # None
47 if event == 'line':
---> 48 return self.dispatch_line(frame)
49 if event == 'call':
50 return self.dispatch_call(frame, arg)

/sw/lib/python2.7/bdb.pyc in dispatch_line(self, frame)
64 def dispatch_line(self, frame):
65 if self.stop_here(frame) or self.break_here(frame):
---> 66 self.user_line(frame)
67 if self.quitting: raise BdbQuit
68 return self.trace_dispatch

/Users/aaronmeurer/Documents/pudb/pudb/debugger.pyc in user_line(self, frame)
237 self.ui.update_breakpoints()
238
--> 239 self.interaction(frame)
240
241 def user_return(self, frame, return_value):

/Users/aaronmeurer/Documents/pudb/pudb/debugger.pyc in interaction(self, frame, exc_tuple)
206 self.set_frame_index(index)
207
--> 208 self.ui.call_with_ui(self.ui.interaction, exc_tuple)
209
210 def get_stack_situation_id(self):

/Users/aaronmeurer/Documents/pudb/pudb/debugger.pyc in call_with_ui(self, f, *args, **kwargs)
1240 self.show()
1241 try:
-> 1242 return f(*args, **kwargs)
1243 finally:
1244 self.hide()

/Users/aaronmeurer/Documents/pudb/pudb/debugger.pyc in interaction(self, exc_tuple)
1357
1358 self.caption.set_text(caption)
-> 1359 self.event_loop()
1360
1361 def set_current_file(self, fname):

/Users/aaronmeurer/Documents/pudb/pudb/debugger.pyc in event_loop(self, toplevel)
1316 self.size = self.screen.get_cols_rows()
1317 else:
-> 1318 toplevel.keypress(self.size, k)
1319
1320 return self.quit_event_loop

/Users/aaronmeurer/Documents/pudb/pudb/ui_tools.pyc in keypress(self, size, key)
85 for mask, handler in self.event_listeners:
86 if mask is None or mask == key:
---> 87 return handler(self, size, key)
88
89 return result

/Users/aaronmeurer/Documents/pudb/pudb/debugger.pyc in run_shell(w, size, key)
1025
1026 runner(curframe.f_locals, curframe.f_globals,
-> 1027 first_shell_run)
1028
1029 self.screen.start()

/Users/aaronmeurer/Documents/pudb/pudb/shell.pyc in run_ipython_shell_v11(locals, globals, first_time)
106 old_globals = shell.user_global_ns
107 # Update shell with current namespace

--> 108 _update_ns(shell, locals, globals)
109 shell.mainloop(banner)
110 # Restore originating namespace

/Users/aaronmeurer/Documents/pudb/pudb/shell.pyc in _update_ns(shell, locals, globals)
114 '''Update the IPython 0.11 namespace at every visit'''
115 shell.user_ns = locals.copy()
--> 116 shell.user_global_ns = globals
117 shell.init_user_ns()
118 shell.init_completer()

AttributeError: can't set attribute
```

Then, when I execute any command that produces an Out result, I get:

```py
In [8]: 1
Out[8]: 1
---------------------------------------------------------------------------
KeyError Traceback (most recent call last)
/Users/aaronmeurer/Documents/Python/sympy/sympy/ in ()
----> 1 1

/Users/aaronmeurer/Documents/ipython/IPython/core/displayhook.py in __call__(self, result)
238 format_dict = self.compute_format_data(result)
239 self.write_format_data(format_dict)
--> 240 self.update_user_ns(result)
241 self.log_output(format_dict)
242 self.finish_displayhook()

/Users/aaronmeurer/Documents/ipython/IPython/core/displayhook.py in update_user_ns(self, result)
186
187 # Avoid recursive reference when displaying _oh/Out

--> 188 if result is not self.shell.user_ns['_oh']:
189 if len(self.shell.user_ns['_oh']) >= self.cache_size and self.do_full_cache:
190 warn('Output cache limit (currently '+

KeyError: '_oh'
```

And finally, when I CTRL-D, I get

```pytb
Error in atexit._run_exitfuncs:
Traceback (most recent call last):
File "/sw/lib/python2.7/atexit.py", line 24, in _run_exitfuncs
func(*targs, **kargs)
File "/Users/aaronmeurer/Documents/ipython/IPython/core/interactiveshell.py", line 2743, in atexit_operations
self.reset(new_session=False)
File "/Users/aaronmeurer/Documents/ipython/IPython/core/interactiveshell.py", line 1131, in reset
self.displayhook.flush()
File "/Users/aaronmeurer/Documents/ipython/IPython/core/displayhook.py", line 255, in flush
self.shell.user_ns['_oh'].clear()
KeyError: '_oh'
Error in sys.exitfunc:
Traceback (most recent call last):
File "/sw/lib/python2.7/atexit.py", line 24, in _run_exitfuncs
func(*targs, **kargs)
File "/Users/aaronmeurer/Documents/ipython/IPython/core/interactiveshell.py", line 2743, in atexit_operations
self.reset(new_session=False)
File "/Users/aaronmeurer/Documents/ipython/IPython/core/interactiveshell.py", line 1131, in reset
self.displayhook.flush()
File "/Users/aaronmeurer/Documents/ipython/IPython/core/displayhook.py", line 255, in flush
self.shell.user_ns['_oh'].clear()
KeyError: '_oh'
```

which kills everything and brings me back to bash (I think there are two tracebacks because I started pudb from within IPython).