Skip to content

Conversation

@anntzer
Copy link
Contributor

@anntzer anntzer commented May 9, 2016

If e.g. "c" is a variable currently visible, then "c" should print it
instead of running the "continue" Pdb command. This idea was first
implemented by pdb++.

It is possible to force the standard pdb behavior (bypass variable
checking) by prefixing the command with "!!", e.g. "!!c" to continue.

If e.g. "c" is a variable currently visible, then "c" should print it
instead of running the "continue" Pdb command.  This idea was first
implemented by pdb++.

It is possible to force the standard pdb behavior (bypass variable
checking) by prefixing the command with "!!", e.g. "!!c" to continue.
# with the same name exists.
cmd, arg, newline = super(Pdb, self).parseline(line)
if cmd in self.curframe.f_globals or cmd in self.curframe.f_locals:
return super(Pdb, self).parseline("!" + line)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So !... means to execute the line (after !) as regular Python code?

Copy link
Contributor Author

@anntzer anntzer May 10, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is normal pdb behavior: link

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for confirming :-)

@takluyver
Copy link
Member

This looks reasonable to me. Pinging @gotcha for the external ipdb package - any thoughts on this?

@takluyver
Copy link
Member

This seems to be causing a build hang on Python 2.7 on Travis, though. I restarted it, but the same happened again. Can you investigate?

@anntzer
Copy link
Contributor Author

anntzer commented May 10, 2016

I didn't have any hangs, but did find another bug (super needs new-style classes, so be it). I also have some other failures in iptest utils which seem unrelated:

======================================================================
ERROR: Failure: ImportError (cannot import name json_clean)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/antony/venvs/ipy2/lib/python2.7/site-packages/nose/loader.py", line 418, in loadTestsFromName
    addr.filename, addr.module)
  File "/home/antony/venvs/ipy2/lib/python2.7/site-packages/nose/importer.py", line 47, in importFromPath
    return self.importFromDir(dir_path, fqname)
  File "/home/antony/venvs/ipy2/lib/python2.7/site-packages/nose/importer.py", line 94, in importFromDir
    mod = load_module(part_fqname, fh, filename, desc)
  File "/home/antony/venvs/ipy2/lib/python2.7/site-packages/IPython/utils/tests/test_jsonutil.py", line 14, in <module>
    from ..jsonutil import json_clean, encode_images
ImportError: cannot import name json_clean

======================================================================
ERROR: IPython.utils.tests.test_localinterfaces.test_load_ips
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/antony/venvs/ipy2/lib/python2.7/site-packages/nose/case.py", line 197, in runTest
    self.test(*self.arg)
  File "/home/antony/venvs/ipy2/lib/python2.7/site-packages/IPython/utils/tests/test_localinterfaces.py", line 12, in test_load_ips
    localinterfaces._load_ips.called = False
AttributeError: 'module' object has no attribute '_load_ips'

======================================================================
ERROR: Failure: ImportError (cannot import name EventfulList)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/antony/venvs/ipy2/lib/python2.7/site-packages/nose/loader.py", line 418, in loadTestsFromName
    addr.filename, addr.module)
  File "/home/antony/venvs/ipy2/lib/python2.7/site-packages/nose/importer.py", line 47, in importFromPath
    return self.importFromDir(dir_path, fqname)
  File "/home/antony/venvs/ipy2/lib/python2.7/site-packages/nose/importer.py", line 94, in importFromDir
    mod = load_module(part_fqname, fh, filename, desc)
  File "/home/antony/venvs/ipy2/lib/python2.7/site-packages/IPython/utils/tests/test_traitlets.py", line 18, in <module>
    from IPython.utils.traitlets import (
ImportError: cannot import name EventfulList
======================================================================
FAIL: IPython.utils.tests.test_shimmodule.test_shim_warning
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/antony/venvs/ipy2/lib/python2.7/site-packages/nose/case.py", line 197, in runTest
    self.test(*self.arg)
  File "/home/antony/venvs/ipy2/lib/python2.7/site-packages/IPython/utils/tests/test_shimmodule.py", line 14, in test_shim_warning
    assert len(w) == 1
AssertionError: 
>>  assert len([<warnings.WarningMessage object at 0x7fb13d2c9d90>, <warnings.WarningMessage object at 0x7fb13d2c9c50>, <warnings.WarningMessage object at 0x7fb13d2c9890>, <warnings.WarningMessage object at 0x7fb13d2f6fd0>]) == 1
    assert issubclass([<warnings.WarningMessage object at 0x7fb13d2c9d90>, <warnings.WarningMessage object at 0x7fb13d2c9c50>, <warnings.WarningMessage object at 0x7fb13d2c9890>, <warnings.WarningMessage object at 0x7fb13d2f6fd0>][-1].category, ShimWarning)

@takluyver
Copy link
Member

Those unrelated failures look like you may have a leftover test file from an older version of IPython.

@takluyver
Copy link
Member

I'm surprised that making a new style class like that works: I would expect that the base class it inherits from would have to be new style as well for super() to work. Have you tested this manually in Python 2?

@anntzer
Copy link
Contributor Author

anntzer commented May 10, 2016

I did, and you can see the tests passing too. I guess super just needs to find the superclass of the current class to work.

@takluyver
Copy link
Member

Thanks. I'll give @gotcha a chance to have a look, but I think this is looking OK.

@gotcha
Copy link

gotcha commented May 10, 2016

ipdb does only wrap IPython, so I would be surprised if ipdb code impact this in any way.

@takluyver
Copy link
Member

No, I don't think it should. But I thought you might want to have a look at it, since you probably use the debugger a fair bit :-)

@takluyver takluyver added this to the 5.0 milestone May 20, 2016
@takluyver takluyver merged commit c0f292b into ipython:master May 20, 2016
@anntzer anntzer deleted the ipdb-smart-command branch May 20, 2016 23:03
takluyver added a commit to takluyver/ipython that referenced this pull request Nov 9, 2016
This is a manual revert of PR ipython#9449

Closes ipythongh-10037

I don't think there's currently enough support for smart command mode to
be worth adding a config option for it now. We can always add this
later.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants