-noreadline + pdb => crash in ipython 0.10

Bug #495173 reported by Gerard
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
IPython
Fix Committed
Medium
Fernando Perez

Bug Description

From a terminal:

ipython -norealine
In [1]: pdb
In [2]: x = y

causes a crash. The full log and crash report are below:

gbrunick$ ipython -noreadline
Python 2.6.2 (release26-maint, Apr 19 2009, 01:56:41)
Type "copyright", "credits" or "license" for more information.

IPython 0.10 -- An enhanced Interactive Python.
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object'. ?object also works, ?? prints more.

In [1]: pdb
Automatic pdb calling has been turned ON

In [2]: x=y
---------------------------------------------------------------------------
NameError Traceback (most recent call last)

/home/gbrunick/<ipython console> in <module>()

NameError: name 'y' is not defined
---------------------------------------------------------------------------
AttributeError Python 2.6.2: /usr/bin/python
                                                   Thu Dec 10 13:16:28 2009
A problem occured executing Python code. Here is the sequence of function
calls leading up to the error, with the most recent (innermost) call last.

/home/gbrunick/usr-ubuntu/bin/ipython in <module>()
     13
     14 [or simply IPython.Shell.IPShell().mainloop(1) ]
     15
     16 and IPython will be your working environment when you start python. The final
     17 sys.exit() call will make python exit transparently when IPython finishes, so
     18 you don't have an extra prompt to get out of.
     19
     20 This is probably useful to developers who manage multiple Python versions and
     21 don't want to have correspondingly multiple IPython versions. Note that in
     22 this mode, there is no way to pass IPython any command-line options, as those
     23 are trapped first by Python itself.
     24 """
     25
     26 import IPython.Shell
     27
---> 28 IPython.Shell.start().mainloop()
        global IPython.Shell.start.mainloop = undefined
     29
     30
     31
     32
     33
     34
     35
     36
     37
     38
     39
     40
     41
     42
     43

/home/gbrunick/usr-ubuntu/lib/python2.6/site-packages/IPython/Shell.pyc in mainloop(self=<IPython.Shell.IPShell instance at 0xb7d805ec>, sys_exit=0, banner=None)
     61 #-----------------------------------------------------------------------------
     62 # This class is trivial now, but I want to have it in to publish a clean
     63 # interface. Later when the internals are reorganized, code that uses this
     64 # shouldn't have to change.
     65
     66 class IPShell:
     67 """Create an IPython instance."""
     68
     69 def __init__(self,argv=None,user_ns=None,user_global_ns=None,
     70 debug=1,shell_class=InteractiveShell):
     71 self.IP = make_IPython(argv,user_ns=user_ns,
     72 user_global_ns=user_global_ns,
     73 debug=debug,shell_class=shell_class)
     74
     75 def mainloop(self,sys_exit=0,banner=None):
---> 76 self.IP.mainloop(banner)
        global For = undefined
        global more = undefined
        global details = undefined
        global see = undefined
        global the = undefined
        global __call__ = undefined
        global method = undefined
        global below. = undefined
     77 if sys_exit:
     78 sys.exit()
     79
     80 #-----------------------------------------------------------------------------
     81 def kill_embedded(self,parameter_s=''):
     82 """%kill_embedded : deactivate for good the current embedded IPython.
     83
     84 This function (after asking for confirmation) sets an internal flag so that
     85 an embedded IPython will never activate again. This is useful to
     86 permanently disable a shell that is being called inside a loop: once you've
     87 figured out what you needed from it, you may then kill it and the program
     88 will then continue to run without the interactive shell interfering again.
     89 """
     90
     91 kill = ask_yes_no("Are you sure you want to kill this embedded instance "

/home/gbrunick/usr-ubuntu/lib/python2.6/site-packages/IPython/iplib.pyc in mainloop(self=<IPython.iplib.InteractiveShell object at 0xb7d8082c>, banner="Python 2.6.2 (release26-maint, Apr 19 2009, 01:5...ut 'object'. ?object also works, ?? prints more.\n")
   1745 if not self.rc.banner:
   1746 banner = ''
   1747 # banner is string? Use it directly!
   1748 elif isinstance(self.rc.banner,basestring):
   1749 banner = self.rc.banner
   1750 else:
   1751 banner = self.BANNER+self.banner2
   1752
   1753 # if you run stuff with -c <cmd>, raw hist is not updated
   1754 # ensure that it's in sync
   1755 if len(self.input_hist) != len (self.input_hist_raw):
   1756 self.input_hist_raw = InputList(self.input_hist)
   1757
   1758 while 1:
   1759 try:
-> 1760 self.interact(banner)
   1761 #self.interact_with_readline()
   1762
   1763 # XXX for testing of a readline-decoupled repl loop, call
   1764 # interact_with_readline above
   1765
   1766 break
   1767 except KeyboardInterrupt:
   1768 # this should not be necessary, but KeyboardInterrupt
   1769 # handling seems rather unpredictable...
   1770 self.write("\nKeyboardInterrupt in interact()\n")
   1771
   1772 def exec_init_cmd(self):
   1773 """Execute a command given at the command line.
   1774
   1775 This emulates Python's -c option."""

/home/gbrunick/usr-ubuntu/lib/python2.6/site-packages/IPython/iplib.pyc in interact(self=<IPython.iplib.InteractiveShell object at 0xb7d8082c>, banner="Python 2.6.2 (release26-maint, Apr 19 2009, 01:5...ut 'object'. ?object also works, ?? prints more.\n")
   1983 if self.autoindent:
   1984 self.rl_do_indent = False
   1985 self.readline_startup_hook(None)
   1986 self.write('\n')
   1987 self.exit()
   1988 except bdb.BdbQuit:
   1989 warn('The Python debugger has exited with a BdbQuit exception.\n'
   1990 'Because of how pdb handles the stack, it is impossible\n'
   1991 'for IPython to properly format this particular exception.\n'
   1992 'IPython will resume normal operation.')
   1993 except:
   1994 # exceptions here are VERY RARE, but they can be triggered
   1995 # asynchronously by signal handlers, for example.
   1996 self.showtraceback()
   1997 else:
-> 1998 more = self.push(line)
   1999 if (self.SyntaxTB.last_syntax_error and
   2000 self.rc.autoedit_syntax):
   2001 self.edit_syntax_error()
   2002
   2003 # We are off again...
   2004 __builtin__.__dict__['__IPYTHON__active'] -= 1
   2005
   2006 def excepthook(self, etype, value, tb):
   2007 """One more defense for GUI apps that call sys.excepthook.
   2008
   2009 GUI frameworks like wxPython trap exceptions and call
   2010 sys.excepthook themselves. I guess this is a feature that
   2011 enables them to keep running after exceptions that would
   2012 otherwise kill their mainloop. This is a bother for IPython
   2013 which excepts to catch all of the program exceptions with a try:

/home/gbrunick/usr-ubuntu/lib/python2.6/site-packages/IPython/iplib.pyc in push(self=<IPython.iplib.InteractiveShell object at 0xb7d8082c>, line=u'x=y')
   2287 is reset; otherwise, the command is incomplete, and the buffer
   2288 is left as it was after the line was appended. The return
   2289 value is 1 if more input is required, 0 if the line was dealt
   2290 with in some way (this is the same as runsource()).
   2291 """
   2292
   2293 # autoindent management should be done here, and not in the
   2294 # interactive loop, since that one is only seen by keyboard input. We
   2295 # need this done correctly even for code run via runlines (which uses
   2296 # push).
   2297
   2298 #print 'push line: <%s>' % line # dbg
   2299 for subline in line.splitlines():
   2300 self.autoindent_update(subline)
   2301 self.buffer.append(line)
-> 2302 more = self.runsource('\n'.join(self.buffer), self.filename)
   2303 if not more:
   2304 self.resetbuffer()
   2305 return more
   2306
   2307 def split_user_input(self, line):
   2308 # This is really a hold-over to support ipapi and some extensions
   2309 return prefilter.splitUserInput(line)
   2310
   2311 def resetbuffer(self):
   2312 """Reset the input buffer."""
   2313 self.buffer[:] = []
   2314
   2315 def raw_input(self,prompt='',continue_prompt=False):
   2316 """Write a prompt and read a line.
   2317

/home/gbrunick/usr-ubuntu/lib/python2.6/site-packages/IPython/iplib.pyc in runsource(self=<IPython.iplib.InteractiveShell object at 0xb7d8082c>, source='x=y', filename='<ipython console>', symbol='single')
   2213 # Case 1
   2214 self.showsyntaxerror(filename)
   2215 return None
   2216
   2217 if code is None:
   2218 # Case 2
   2219 return True
   2220
   2221 # Case 3
   2222 # We store the code object so that threaded shells and
   2223 # custom exception handlers can access all this info if needed.
   2224 # The source corresponding to this can be obtained from the
   2225 # buffer attribute as '\n'.join(self.buffer).
   2226 self.code_to_run = code
   2227 # now actually execute the code object
-> 2228 if self.runcode(code) == 0:
   2229 return False
   2230 else:
   2231 return None
   2232
   2233 def runcode(self,code_obj):
   2234 """Execute a code object.
   2235
   2236 When an exception occurs, self.showtraceback() is called to display a
   2237 traceback.
   2238
   2239 Return value: a flag indicating whether the code to be run completed
   2240 successfully:
   2241
   2242 - 0: successful execution.
   2243 - 1: an error occurred.

/home/gbrunick/usr-ubuntu/lib/python2.6/site-packages/IPython/iplib.pyc in runcode(self=<IPython.iplib.InteractiveShell object at 0xb7d8082c>, code_obj=<code object <module> at 0x8d539b0, file "<ipython console>", line 1>)
   2255 try:
   2256 self.hooks.pre_runcode_hook()
   2257 exec code_obj in self.user_global_ns, self.user_ns
   2258 finally:
   2259 # Reset our crash handler in place
   2260 sys.excepthook = old_excepthook
   2261 except SystemExit:
   2262 self.resetbuffer()
   2263 self.showtraceback()
   2264 warn("Type %exit or %quit to exit IPython "
   2265 "(%Exit or %Quit do so unconditionally).",level=1)
   2266 except self.custom_exceptions:
   2267 etype,value,tb = sys.exc_info()
   2268 self.CustomTB(etype,value,tb)
   2269 except:
-> 2270 self.showtraceback()
   2271 else:
   2272 outflag = 0
   2273 if softspace(sys.stdout, 0):
   2274 print
   2275 # Flush out code object which has been run (and source)
   2276 self.code_to_run = None
   2277 return outflag
   2278
   2279 def push(self, line):
   2280 """Push a line to the interpreter.
   2281
   2282 The line should not have a trailing newline; it may have
   2283 internal newlines. The line is appended to a buffer and the
   2284 interpreter's runsource() method is called with the
   2285 concatenated contents of the buffer as source. If this

/home/gbrunick/usr-ubuntu/lib/python2.6/site-packages/IPython/iplib.pyc in showtraceback(self=<IPython.iplib.InteractiveShell object at 0xb7d8082c>, exc_tuple=None, filename=None, tb_offset=None)
   1714 self.showsyntaxerror(filename)
   1715 elif etype is IPython.ipapi.UsageError:
   1716 print "UsageError:", value
   1717 else:
   1718 # WARNING: these variables are somewhat deprecated and not
   1719 # necessarily safe to use in a threaded environment, but tools
   1720 # like pdb depend on their existence, so let's set them. If we
   1721 # find problems in the field, we'll need to revisit their use.
   1722 sys.last_type = etype
   1723 sys.last_value = value
   1724 sys.last_traceback = tb
   1725
   1726 if etype in self.custom_exceptions:
   1727 self.CustomTB(etype,value,tb)
   1728 else:
-> 1729 self.InteractiveTB(etype,value,tb,tb_offset=tb_offset)
   1730 if self.InteractiveTB.call_pdb and self.has_readline:
   1731 # pdb mucks up readline, fix it back
   1732 self.set_completer()
   1733 except KeyboardInterrupt:
   1734 self.write("\nKeyboardInterrupt\n")
   1735
   1736 def mainloop(self,banner=None):
   1737 """Creates the local namespace and starts the mainloop.
   1738
   1739 If an optional banner argument is given, it will override the
   1740 internally created default banner."""
   1741
   1742 if self.rc.c: # Emulate Python's -c option
   1743 self.exec_init_cmd()
   1744 if banner is None:

/home/gbrunick/usr-ubuntu/lib/python2.6/site-packages/IPython/ultraTB.pyc in __call__(self=<IPython.ultraTB.AutoFormattedTB instance at 0x8d4046c>, etype=<type 'exceptions.NameError'>, evalue=NameError("name 'y' is not defined",), etb=<traceback object at 0x8db1374>, out=<IPython.genutils.IOStream instance at 0x8bb5f2c>, tb_offset=None)
    989 - tb_offset: the number of frames to skip over in the stack, on a
    990 per-call basis (this overrides temporarily the instance's tb_offset
    991 given at initialization time. """
    992
    993 if out is None:
    994 out = Term.cerr
    995 Term.cout.flush()
    996 if tb_offset is not None:
    997 tb_offset, self.tb_offset = self.tb_offset, tb_offset
    998 print >> out, self.text(etype, evalue, etb)
    999 self.tb_offset = tb_offset
   1000 else:
   1001 print >> out, self.text(etype, evalue, etb)
   1002 out.flush()
   1003 try:
-> 1004 self.debugger()
   1005 except KeyboardInterrupt:
   1006 print "\nKeyboardInterrupt"
   1007
   1008 def text(self,etype=None,value=None,tb=None,context=5,mode=None):
   1009 if etype is None:
   1010 etype,value,tb = sys.exc_info()
   1011 self.tb = tb
   1012 return FormattedTB.text(self,etype,value,tb,context=5,mode=mode)
   1013
   1014 #---------------------------------------------------------------------------
   1015 # A simple class to preserve Nathan's original functionality.
   1016 class ColorTB(FormattedTB):
   1017 """Shorthand to initialize a FormattedTB in Linux colors mode."""
   1018 def __init__(self,color_scheme='Linux',call_pdb=0):
   1019 FormattedTB.__init__(self,color_scheme=color_scheme,

/home/gbrunick/usr-ubuntu/lib/python2.6/site-packages/IPython/ultraTB.pyc in debugger(self=<IPython.ultraTB.AutoFormattedTB instance at 0x8d4046c>, force=False)
    848 # for pdb
    849 dhook = sys.displayhook
    850 sys.displayhook = sys.__displayhook__
    851 self.pdb.reset()
    852 # Find the right frame so we don't pop up inside ipython itself
    853 if hasattr(self,'tb'):
    854 etb = self.tb
    855 else:
    856 etb = self.tb = sys.last_traceback
    857 while self.tb.tb_next is not None:
    858 self.tb = self.tb.tb_next
    859 try:
    860 if etb and etb.tb_next:
    861 etb = etb.tb_next
    862 self.pdb.botframe = etb.tb_frame
--> 863 self.pdb.interaction(self.tb.tb_frame, self.tb)
    864 finally:
    865 sys.displayhook = dhook
    866
    867 if hasattr(self,'tb'):
    868 del self.tb
    869
    870 def handler(self, info=None):
    871 (etype, evalue, etb) = info or sys.exc_info()
    872 self.tb = etb
    873 Term.cout.flush()
    874 print >> Term.cerr, self.text(etype, evalue, etb)
    875 Term.cerr.flush()
    876
    877 # Changed so an instance can just be called as VerboseTB_inst() and print
    878 # out the right info on its own.

/home/gbrunick/usr-ubuntu/lib/python2.6/site-packages/IPython/Debugger.pyc in interaction(self=<IPython.Debugger.Pdb instance at 0x8db0ecc>, frame=<frame object at 0x8d8bffc>, traceback=<traceback object at 0x8db1324>)
    265
    266 cst['LightBG'].colors.breakpoint_enabled = C.LightRed
    267 cst['LightBG'].colors.breakpoint_disabled = C.Red
    268
    269 self.set_colors(color_scheme)
    270
    271 # Add a python parser so we can syntax highlight source while
    272 # debugging.
    273 self.parser = PyColorize.Parser()
    274
    275 def set_colors(self, scheme):
    276 """Shorthand access to the color table scheme selector method."""
    277 self.color_scheme_table.set_active_scheme(scheme)
    278
    279 def interaction(self, frame, traceback):
--> 280 __IPYTHON__.set_completer_frame(frame)
    281 OldPdb.interaction(self, frame, traceback)
    282
    283 def new_do_up(self, arg):
    284 OldPdb.do_up(self, arg)
    285 __IPYTHON__.set_completer_frame(self.curframe)
    286 do_u = do_up = decorate_fn_with_doc(new_do_up, OldPdb.do_up)
    287
    288 def new_do_down(self, arg):
    289 OldPdb.do_down(self, arg)
    290 __IPYTHON__.set_completer_frame(self.curframe)
    291
    292 do_d = do_down = decorate_fn_with_doc(new_do_down, OldPdb.do_down)
    293
    294 def new_do_frame(self, arg):
    295 OldPdb.do_frame(self, arg)

/home/gbrunick/usr-ubuntu/lib/python2.6/site-packages/IPython/iplib.pyc in set_completer_frame(self=<IPython.iplib.InteractiveShell object at 0xb7d8082c>, frame=<frame object at 0x8d8bffc>)
   1249 comps = {}
   1250 while True:
   1251 newcomp = complete(text,state,line_buffer=text)
   1252 if newcomp is None:
   1253 break
   1254 comps[newcomp] = 1
   1255 state += 1
   1256 outcomps = comps.keys()
   1257 outcomps.sort()
   1258 #print "T:",text,"OC:",outcomps # dbg
   1259 #print "vars:",self.user_ns.keys()
   1260 return outcomps
   1261
   1262 def set_completer_frame(self, frame=None):
   1263 if frame:
-> 1264 self.Completer.namespace = frame.f_locals
   1265 self.Completer.global_namespace = frame.f_globals
   1266 else:
   1267 self.Completer.namespace = self.user_ns
   1268 self.Completer.global_namespace = self.user_global_ns
   1269
   1270 def init_auto_alias(self):
   1271 """Define some aliases automatically.
   1272
   1273 These are ALL parameter-less aliases"""
   1274
   1275 for alias,cmd in self.auto_alias:
   1276 self.getapi().defalias(alias,cmd)
   1277
   1278
   1279 def alias_table_validate(self,verbose=0):

AttributeError: 'InteractiveShell' object has no attribute 'Completer'

**********************************************************************

Oops, IPython crashed. We do our best to make it stable, but...

A crash report was automatically generated with the following information:
  - A verbatim copy of the crash traceback.
  - A copy of your input history during this session.
  - Data on your current IPython configuration.

It was left in the file named:
 '/home/gbrunick/.ipython/IPython_crash_report.txt'
If you can email this file to the developers, the information in it will help
them in understanding and correcting the problem.

You can mail it to: Fernando Perez at <email address hidden>
with the subject 'IPython Crash Report'.

If you want to do it now, the following command will work (under Unix):
mail -s 'IPython Crash Report' <email address hidden> < /home/gbrunick/.ipython/IPython_crash_report.txt

To ensure accurate tracking of this issue, please file a report about it at:
https://bugs.launchpad.net/ipython/+filebug

***************************************************************************

IPython post-mortem report

IPython version: 0.10

BZR revision : 1210

Platform info : os.name -> posix, sys.platform -> linux2

***************************************************************************

Current user configuration structure:

{'Version': 0,
 '__allownew': True,
 'alias': [],
 'args': [],
 'autocall': 1,
 'autoedit_syntax': 0,
 'autoexec': [],
 'autoindent': 1,
 'automagic': 1,
 'banner': 1,
 'c': '',
 'cache_size': 1000,
 'classic': 0,
 'color_info': 1,
 'colors': 'NoColor',
 'confirm_exit': 1,
 'debug': 0,
 'deep_reload': 0,
 'editor': 'emacsclient',
 'embedded': False,
 'execfile': [],
 'execute': [''],
 'gthread': 0,
 'help': 0,
 'import_all': [],
 'import_mod': [],
 'import_some': [[]],
 'include': [],
 'interact': 0,
 'ipythondir': u'/home/gbrunick/.ipython',
 'log': 0,
 'logfile': '',
 'logplay': '',
 'magic_docstrings': 0,
 'messages': 1,
 'multi_line_specials': 1,
 'nosep': 0,
 'object_info_string_level': 0,
 'opts': Struct({'__allownew': True, 'readline': 0}),
 'pdb': 0,
 'pprint': 1,
 'profile': '',
 'prompt_in1': 'In [\\#]: ',
 'prompt_in2': ' .\\D.: ',
 'prompt_out': 'Out[\\#]: ',
 'prompts_pad_left': 1,
 'pydb': 0,
 'pylab': 0,
 'pylab_import_all': 1,
 'q4thread': 0,
 'qthread': 0,
 'quick': 0,
 'quiet': 0,
 'rcfile': 'ipythonrc',
 'readline': 0,
 'readline_merge_completions': 1,
 'readline_omit__names': 0,
 'readline_parse_and_bind': ['tab: complete',
                             '"\\C-l": possible-completions',
                             'set show-all-if-ambiguous on',
                             '"\\C-o": tab-insert',
                             '"\\M-i": " "',
                             '"\\M-o": "\\d\\d\\d\\d"',
                             '"\\M-I": "\\d\\d\\d\\d"',
                             '"\\C-r": reverse-search-history',
                             '"\\C-s": forward-search-history',
                             '"\\C-p": history-search-backward',
                             '"\\C-n": history-search-forward',
                             '"\\e[A": history-search-backward',
                             '"\\e[B": history-search-forward',
                             '"\\C-k": kill-line',
                             '"\\C-u": unix-line-discard'],
 'readline_remove_delims': '-/~',
 'screen_length': -2,
 'separate_in': '\n',
 'separate_out': '',
 'separate_out2': '',
 'system_header': 'IPython system call: ',
 'system_verbose': 0,
 'term_title': 1,
 'tk': 0,
 'upgrade': 0,
 'wildcards_case_sensitive': 1,
 'wthread': 0,
 'wxversion': '0',
 'xmode': 'Context'}

***************************************************************************

Crash traceback:

---------------------------------------------------------------------------
AttributeError Python 2.6.2: /usr/bin/python
                                                   Thu Dec 10 13:16:28 2009
A problem occured executing Python code. Here is the sequence of function
calls leading up to the error, with the most recent (innermost) call last.

/home/gbrunick/usr-ubuntu/bin/ipython in <module>()
     13
     14 [or simply IPython.Shell.IPShell().mainloop(1) ]
     15
     16 and IPython will be your working environment when you start python. The final
     17 sys.exit() call will make python exit transparently when IPython finishes, so
     18 you don't have an extra prompt to get out of.
     19
     20 This is probably useful to developers who manage multiple Python versions and
     21 don't want to have correspondingly multiple IPython versions. Note that in
     22 this mode, there is no way to pass IPython any command-line options, as those
     23 are trapped first by Python itself.
     24 """
     25
     26 import IPython.Shell
     27
---> 28 IPython.Shell.start().mainloop()
        global IPython.Shell.start.mainloop = undefined
     29
     30
     31
     32
     33
     34
     35
     36
     37
     38
     39
     40
     41
     42
     43

/home/gbrunick/usr-ubuntu/lib/python2.6/site-packages/IPython/Shell.pyc in mainloop(self=<IPython.Shell.IPShell instance at 0xb7d805ec>, sys_exit=0, banner=None)
     61 #-----------------------------------------------------------------------------
     62 # This class is trivial now, but I want to have it in to publish a clean
     63 # interface. Later when the internals are reorganized, code that uses this
     64 # shouldn't have to change.
     65
     66 class IPShell:
     67 """Create an IPython instance."""
     68
     69 def __init__(self,argv=None,user_ns=None,user_global_ns=None,
     70 debug=1,shell_class=InteractiveShell):
     71 self.IP = make_IPython(argv,user_ns=user_ns,
     72 user_global_ns=user_global_ns,
     73 debug=debug,shell_class=shell_class)
     74
     75 def mainloop(self,sys_exit=0,banner=None):
---> 76 self.IP.mainloop(banner)
        global For = undefined
        global more = undefined
        global details = undefined
        global see = undefined
        global the = undefined
        global __call__ = undefined
        global method = undefined
        global below. = undefined
     77 if sys_exit:
     78 sys.exit()
     79
     80 #-----------------------------------------------------------------------------
     81 def kill_embedded(self,parameter_s=''):
     82 """%kill_embedded : deactivate for good the current embedded IPython.
     83
     84 This function (after asking for confirmation) sets an internal flag so that
     85 an embedded IPython will never activate again. This is useful to
     86 permanently disable a shell that is being called inside a loop: once you've
     87 figured out what you needed from it, you may then kill it and the program
     88 will then continue to run without the interactive shell interfering again.
     89 """
     90
     91 kill = ask_yes_no("Are you sure you want to kill this embedded instance "

/home/gbrunick/usr-ubuntu/lib/python2.6/site-packages/IPython/iplib.pyc in mainloop(self=<IPython.iplib.InteractiveShell object at 0xb7d8082c>, banner="Python 2.6.2 (release26-maint, Apr 19 2009, 01:5...ut 'object'. ?object also works, ?? prints more.\n")
   1745 if not self.rc.banner:
   1746 banner = ''
   1747 # banner is string? Use it directly!
   1748 elif isinstance(self.rc.banner,basestring):
   1749 banner = self.rc.banner
   1750 else:
   1751 banner = self.BANNER+self.banner2
   1752
   1753 # if you run stuff with -c <cmd>, raw hist is not updated
   1754 # ensure that it's in sync
   1755 if len(self.input_hist) != len (self.input_hist_raw):
   1756 self.input_hist_raw = InputList(self.input_hist)
   1757
   1758 while 1:
   1759 try:
-> 1760 self.interact(banner)
   1761 #self.interact_with_readline()
   1762
   1763 # XXX for testing of a readline-decoupled repl loop, call
   1764 # interact_with_readline above
   1765
   1766 break
   1767 except KeyboardInterrupt:
   1768 # this should not be necessary, but KeyboardInterrupt
   1769 # handling seems rather unpredictable...
   1770 self.write("\nKeyboardInterrupt in interact()\n")
   1771
   1772 def exec_init_cmd(self):
   1773 """Execute a command given at the command line.
   1774
   1775 This emulates Python's -c option."""

/home/gbrunick/usr-ubuntu/lib/python2.6/site-packages/IPython/iplib.pyc in interact(self=<IPython.iplib.InteractiveShell object at 0xb7d8082c>, banner="Python 2.6.2 (release26-maint, Apr 19 2009, 01:5...ut 'object'. ?object also works, ?? prints more.\n")
   1983 if self.autoindent:
   1984 self.rl_do_indent = False
   1985 self.readline_startup_hook(None)
   1986 self.write('\n')
   1987 self.exit()
   1988 except bdb.BdbQuit:
   1989 warn('The Python debugger has exited with a BdbQuit exception.\n'
   1990 'Because of how pdb handles the stack, it is impossible\n'
   1991 'for IPython to properly format this particular exception.\n'
   1992 'IPython will resume normal operation.')
   1993 except:
   1994 # exceptions here are VERY RARE, but they can be triggered
   1995 # asynchronously by signal handlers, for example.
   1996 self.showtraceback()
   1997 else:
-> 1998 more = self.push(line)
   1999 if (self.SyntaxTB.last_syntax_error and
   2000 self.rc.autoedit_syntax):
   2001 self.edit_syntax_error()
   2002
   2003 # We are off again...
   2004 __builtin__.__dict__['__IPYTHON__active'] -= 1
   2005
   2006 def excepthook(self, etype, value, tb):
   2007 """One more defense for GUI apps that call sys.excepthook.
   2008
   2009 GUI frameworks like wxPython trap exceptions and call
   2010 sys.excepthook themselves. I guess this is a feature that
   2011 enables them to keep running after exceptions that would
   2012 otherwise kill their mainloop. This is a bother for IPython
   2013 which excepts to catch all of the program exceptions with a try:

/home/gbrunick/usr-ubuntu/lib/python2.6/site-packages/IPython/iplib.pyc in push(self=<IPython.iplib.InteractiveShell object at 0xb7d8082c>, line=u'x=y')
   2287 is reset; otherwise, the command is incomplete, and the buffer
   2288 is left as it was after the line was appended. The return
   2289 value is 1 if more input is required, 0 if the line was dealt
   2290 with in some way (this is the same as runsource()).
   2291 """
   2292
   2293 # autoindent management should be done here, and not in the
   2294 # interactive loop, since that one is only seen by keyboard input. We
   2295 # need this done correctly even for code run via runlines (which uses
   2296 # push).
   2297
   2298 #print 'push line: <%s>' % line # dbg
   2299 for subline in line.splitlines():
   2300 self.autoindent_update(subline)
   2301 self.buffer.append(line)
-> 2302 more = self.runsource('\n'.join(self.buffer), self.filename)
   2303 if not more:
   2304 self.resetbuffer()
   2305 return more
   2306
   2307 def split_user_input(self, line):
   2308 # This is really a hold-over to support ipapi and some extensions
   2309 return prefilter.splitUserInput(line)
   2310
   2311 def resetbuffer(self):
   2312 """Reset the input buffer."""
   2313 self.buffer[:] = []
   2314
   2315 def raw_input(self,prompt='',continue_prompt=False):
   2316 """Write a prompt and read a line.
   2317

/home/gbrunick/usr-ubuntu/lib/python2.6/site-packages/IPython/iplib.pyc in runsource(self=<IPython.iplib.InteractiveShell object at 0xb7d8082c>, source='x=y', filename='<ipython console>', symbol='single')
   2213 # Case 1
   2214 self.showsyntaxerror(filename)
   2215 return None
   2216
   2217 if code is None:
   2218 # Case 2
   2219 return True
   2220
   2221 # Case 3
   2222 # We store the code object so that threaded shells and
   2223 # custom exception handlers can access all this info if needed.
   2224 # The source corresponding to this can be obtained from the
   2225 # buffer attribute as '\n'.join(self.buffer).
   2226 self.code_to_run = code
   2227 # now actually execute the code object
-> 2228 if self.runcode(code) == 0:
   2229 return False
   2230 else:
   2231 return None
   2232
   2233 def runcode(self,code_obj):
   2234 """Execute a code object.
   2235
   2236 When an exception occurs, self.showtraceback() is called to display a
   2237 traceback.
   2238
   2239 Return value: a flag indicating whether the code to be run completed
   2240 successfully:
   2241
   2242 - 0: successful execution.
   2243 - 1: an error occurred.

/home/gbrunick/usr-ubuntu/lib/python2.6/site-packages/IPython/iplib.pyc in runcode(self=<IPython.iplib.InteractiveShell object at 0xb7d8082c>, code_obj=<code object <module> at 0x8d539b0, file "<ipython console>", line 1>)
   2255 try:
   2256 self.hooks.pre_runcode_hook()
   2257 exec code_obj in self.user_global_ns, self.user_ns
   2258 finally:
   2259 # Reset our crash handler in place
   2260 sys.excepthook = old_excepthook
   2261 except SystemExit:
   2262 self.resetbuffer()
   2263 self.showtraceback()
   2264 warn("Type %exit or %quit to exit IPython "
   2265 "(%Exit or %Quit do so unconditionally).",level=1)
   2266 except self.custom_exceptions:
   2267 etype,value,tb = sys.exc_info()
   2268 self.CustomTB(etype,value,tb)
   2269 except:
-> 2270 self.showtraceback()
   2271 else:
   2272 outflag = 0
   2273 if softspace(sys.stdout, 0):
   2274 print
   2275 # Flush out code object which has been run (and source)
   2276 self.code_to_run = None
   2277 return outflag
   2278
   2279 def push(self, line):
   2280 """Push a line to the interpreter.
   2281
   2282 The line should not have a trailing newline; it may have
   2283 internal newlines. The line is appended to a buffer and the
   2284 interpreter's runsource() method is called with the
   2285 concatenated contents of the buffer as source. If this

/home/gbrunick/usr-ubuntu/lib/python2.6/site-packages/IPython/iplib.pyc in showtraceback(self=<IPython.iplib.InteractiveShell object at 0xb7d8082c>, exc_tuple=None, filename=None, tb_offset=None)
   1714 self.showsyntaxerror(filename)
   1715 elif etype is IPython.ipapi.UsageError:
   1716 print "UsageError:", value
   1717 else:
   1718 # WARNING: these variables are somewhat deprecated and not
   1719 # necessarily safe to use in a threaded environment, but tools
   1720 # like pdb depend on their existence, so let's set them. If we
   1721 # find problems in the field, we'll need to revisit their use.
   1722 sys.last_type = etype
   1723 sys.last_value = value
   1724 sys.last_traceback = tb
   1725
   1726 if etype in self.custom_exceptions:
   1727 self.CustomTB(etype,value,tb)
   1728 else:
-> 1729 self.InteractiveTB(etype,value,tb,tb_offset=tb_offset)
   1730 if self.InteractiveTB.call_pdb and self.has_readline:
   1731 # pdb mucks up readline, fix it back
   1732 self.set_completer()
   1733 except KeyboardInterrupt:
   1734 self.write("\nKeyboardInterrupt\n")
   1735
   1736 def mainloop(self,banner=None):
   1737 """Creates the local namespace and starts the mainloop.
   1738
   1739 If an optional banner argument is given, it will override the
   1740 internally created default banner."""
   1741
   1742 if self.rc.c: # Emulate Python's -c option
   1743 self.exec_init_cmd()
   1744 if banner is None:

/home/gbrunick/usr-ubuntu/lib/python2.6/site-packages/IPython/ultraTB.pyc in __call__(self=<IPython.ultraTB.AutoFormattedTB instance at 0x8d4046c>, etype=<type 'exceptions.NameError'>, evalue=NameError("name 'y' is not defined",), etb=<traceback object at 0x8db1374>, out=<IPython.genutils.IOStream instance at 0x8bb5f2c>, tb_offset=None)
    989 - tb_offset: the number of frames to skip over in the stack, on a
    990 per-call basis (this overrides temporarily the instance's tb_offset
    991 given at initialization time. """
    992
    993 if out is None:
    994 out = Term.cerr
    995 Term.cout.flush()
    996 if tb_offset is not None:
    997 tb_offset, self.tb_offset = self.tb_offset, tb_offset
    998 print >> out, self.text(etype, evalue, etb)
    999 self.tb_offset = tb_offset
   1000 else:
   1001 print >> out, self.text(etype, evalue, etb)
   1002 out.flush()
   1003 try:
-> 1004 self.debugger()
   1005 except KeyboardInterrupt:
   1006 print "\nKeyboardInterrupt"
   1007
   1008 def text(self,etype=None,value=None,tb=None,context=5,mode=None):
   1009 if etype is None:
   1010 etype,value,tb = sys.exc_info()
   1011 self.tb = tb
   1012 return FormattedTB.text(self,etype,value,tb,context=5,mode=mode)
   1013
   1014 #---------------------------------------------------------------------------
   1015 # A simple class to preserve Nathan's original functionality.
   1016 class ColorTB(FormattedTB):
   1017 """Shorthand to initialize a FormattedTB in Linux colors mode."""
   1018 def __init__(self,color_scheme='Linux',call_pdb=0):
   1019 FormattedTB.__init__(self,color_scheme=color_scheme,

/home/gbrunick/usr-ubuntu/lib/python2.6/site-packages/IPython/ultraTB.pyc in debugger(self=<IPython.ultraTB.AutoFormattedTB instance at 0x8d4046c>, force=False)
    848 # for pdb
    849 dhook = sys.displayhook
    850 sys.displayhook = sys.__displayhook__
    851 self.pdb.reset()
    852 # Find the right frame so we don't pop up inside ipython itself
    853 if hasattr(self,'tb'):
    854 etb = self.tb
    855 else:
    856 etb = self.tb = sys.last_traceback
    857 while self.tb.tb_next is not None:
    858 self.tb = self.tb.tb_next
    859 try:
    860 if etb and etb.tb_next:
    861 etb = etb.tb_next
    862 self.pdb.botframe = etb.tb_frame
--> 863 self.pdb.interaction(self.tb.tb_frame, self.tb)
    864 finally:
    865 sys.displayhook = dhook
    866
    867 if hasattr(self,'tb'):
    868 del self.tb
    869
    870 def handler(self, info=None):
    871 (etype, evalue, etb) = info or sys.exc_info()
    872 self.tb = etb
    873 Term.cout.flush()
    874 print >> Term.cerr, self.text(etype, evalue, etb)
    875 Term.cerr.flush()
    876
    877 # Changed so an instance can just be called as VerboseTB_inst() and print
    878 # out the right info on its own.

/home/gbrunick/usr-ubuntu/lib/python2.6/site-packages/IPython/Debugger.pyc in interaction(self=<IPython.Debugger.Pdb instance at 0x8db0ecc>, frame=<frame object at 0x8d8bffc>, traceback=<traceback object at 0x8db1324>)
    265
    266 cst['LightBG'].colors.breakpoint_enabled = C.LightRed
    267 cst['LightBG'].colors.breakpoint_disabled = C.Red
    268
    269 self.set_colors(color_scheme)
    270
    271 # Add a python parser so we can syntax highlight source while
    272 # debugging.
    273 self.parser = PyColorize.Parser()
    274
    275 def set_colors(self, scheme):
    276 """Shorthand access to the color table scheme selector method."""
    277 self.color_scheme_table.set_active_scheme(scheme)
    278
    279 def interaction(self, frame, traceback):
--> 280 __IPYTHON__.set_completer_frame(frame)
    281 OldPdb.interaction(self, frame, traceback)
    282
    283 def new_do_up(self, arg):
    284 OldPdb.do_up(self, arg)
    285 __IPYTHON__.set_completer_frame(self.curframe)
    286 do_u = do_up = decorate_fn_with_doc(new_do_up, OldPdb.do_up)
    287
    288 def new_do_down(self, arg):
    289 OldPdb.do_down(self, arg)
    290 __IPYTHON__.set_completer_frame(self.curframe)
    291
    292 do_d = do_down = decorate_fn_with_doc(new_do_down, OldPdb.do_down)
    293
    294 def new_do_frame(self, arg):
    295 OldPdb.do_frame(self, arg)

/home/gbrunick/usr-ubuntu/lib/python2.6/site-packages/IPython/iplib.pyc in set_completer_frame(self=<IPython.iplib.InteractiveShell object at 0xb7d8082c>, frame=<frame object at 0x8d8bffc>)
   1249 comps = {}
   1250 while True:
   1251 newcomp = complete(text,state,line_buffer=text)
   1252 if newcomp is None:
   1253 break
   1254 comps[newcomp] = 1
   1255 state += 1
   1256 outcomps = comps.keys()
   1257 outcomps.sort()
   1258 #print "T:",text,"OC:",outcomps # dbg
   1259 #print "vars:",self.user_ns.keys()
   1260 return outcomps
   1261
   1262 def set_completer_frame(self, frame=None):
   1263 if frame:
-> 1264 self.Completer.namespace = frame.f_locals
   1265 self.Completer.global_namespace = frame.f_globals
   1266 else:
   1267 self.Completer.namespace = self.user_ns
   1268 self.Completer.global_namespace = self.user_global_ns
   1269
   1270 def init_auto_alias(self):
   1271 """Define some aliases automatically.
   1272
   1273 These are ALL parameter-less aliases"""
   1274
   1275 for alias,cmd in self.auto_alias:
   1276 self.getapi().defalias(alias,cmd)
   1277
   1278
   1279 def alias_table_validate(self,verbose=0):

AttributeError: 'InteractiveShell' object has no attribute 'Completer'

***************************************************************************

History of session input:
_ip.magic("pdb ")
x=y

*** Last line of input (may not be in above history):
x=y

Related branches

Revision history for this message
Fernando Perez (fdo.perez) wrote :

Fixed in 0.10.1 series and in trunk. Thanks for the report!

Changed in ipython:
status: New → Fix Committed
assignee: nobody → Fernando Perez (fdo.perez)
milestone: none → 0.10.1
importance: Undecided → Medium
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.