Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

%debug broken in master: invokes missing save_history() method #318

Closed
efiring opened this Issue · 12 comments

4 participants

@efiring

The session below illustrates the AttributeError raised by attempting to use %debug after an Exception has been raised. This is with current master, head is 2b37a36.

Eric

efiring@manini:~$ ipython 
Python 2.6.6 (r266:84292, Sep 15 2010, 16:22:56) 
Type "copyright", "credits" or "license" for more information.

IPython 0.11.dev -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object', use 'object??' for extra details.

In [1]: raise Exception("testing")
---------------------------------------------------------------------------
Exception                                 Traceback (most recent call last)
/home/efiring/ in ()
----> 1 raise Exception("testing")

Exception: testing

In [2]: %debug
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
/home/efiring/ in ()
----> 1 get_ipython().magic(u"debug")

/home/efiring/programs/py/ipython/ipython_git/IPython/core/interactiveshell.pyc in magic(self, arg_s)
   1743             with nested(self.builtin_trap,):
   1744                 result = fn(magic_args)
-> 1745                 return result
   1746 
   1747     def define_magic(self, magicname, func):

/usr/lib/python2.6/contextlib.pyc in __exit__(self, type, value, traceback)
     32                 value = type()
     33             try:
---> 34                 self.gen.throw(type, value, traceback)
     35                 raise RuntimeError("generator didn't stop after throw()")
     36             except StopIteration, exc:

/usr/lib/python2.6/contextlib.pyc in nested(*managers)
    111             vars.append(enter())
    112             exits.append(exit)
--> 113         yield vars
    114     except:
    115         exc = sys.exc_info()

/home/efiring/programs/py/ipython/ipython_git/IPython/core/interactiveshell.pyc in magic(self, arg_s)
   1742             magic_args = self.var_expand(magic_args,1)
   1743             with nested(self.builtin_trap,):
-> 1744                 result = fn(magic_args)
   1745                 return result
   1746 

/home/efiring/programs/py/ipython/ipython_git/IPython/core/magic.pyc in magic_debug(self, parameter_s)
   1254         the %pdb magic for more details.
   1255         """
-> 1256         self.shell.debugger(force=True)
   1257 
   1258     @testdec.skip_doctest

/home/efiring/programs/py/ipython/ipython_git/IPython/core/interactiveshell.pyc in debugger(self, force)
    738             # fallback to our internal debugger

    739             pm = lambda : self.InteractiveTB.debugger(force=True)
--> 740         self.history_saving_wrapper(pm)()
    741 
    742     #-------------------------------------------------------------------------


/home/efiring/programs/py/ipython/ipython_git/IPython/core/interactiveshell.pyc in wrapper()
   1263 
   1264         def wrapper():
-> 1265             self.save_history()
   1266             try:
   1267                 func()

AttributeError: 'TerminalInteractiveShell' object has no attribute 'save_history'

In [3]: 
@efiring

Sorry the markdown rendering is so ghastly; is there some simple way of delimiting a pasted session like this when entering it?

@fperez
Owner
@minrk
Owner

Eric,

The easiest way to prevent markdown from trying to render a block is to wrap it in 'pre' html tags:
<pre>...</pre>

@takluyver
Owner

Sorry, should have done a grep for anything calling save_history(). Fernando (or anyone), what was the purpose of history_saving_wrapper? I assume it's just to suppress any changes that a function could have on history: we need to work out how to do that in the new system. Without doing anything special, as far as I know, debugging commands shouldn't be added to history.

@takluyver
Owner

This should be (and is for me) fixed by pull request #319 - you're welcome to test it.

@fperez
Owner
@takluyver
Owner

Hmm, OK. What's the best way to do that? Can we block readline from recording lines? We could go back to the original readline save/reload functionality with a temp file, or reinitialise readline from the database after a debug session...

Also, does it make sense to use a context manager for this. with readline_no_record?

@fperez
Owner
@takluyver
Owner
@fperez
Owner
@minrk
Owner

The titular bug has been fixed. Should we close this, or let it stay to represent other %debug issues discussed here?

@takluyver
Owner

Actually, we've sorted out the behaviour of readline in those cases as well - there's a ip.readline_no_record context manager. So I'll close this.

@takluyver takluyver closed this
@markvoorhies markvoorhies referenced this issue from a commit in markvoorhies/ipython
@takluyver takluyver Cleanup old calls to save_history and reload_history methods, which w…
…ere removed.

Closes gh-318
7df9676
@ellisonbg ellisonbg referenced this issue from a commit
Commit has since been removed from the repository and is no longer available.
@damianavila damianavila referenced this issue from a commit
Commit has since been removed from the repository and is no longer available.
@mattvonrocketstein mattvonrocketstein referenced this issue from a commit in mattvonrocketstein/ipython
@takluyver takluyver Cleanup old calls to save_history and reload_history methods, which w…
…ere removed.

Closes gh-318
eeeffe9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.