Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ipdb: pdef, pdoc, pinfo magics all broken #2169

Merged
merged 3 commits into from Jul 23, 2012

Conversation

bfroehle
Copy link
Contributor

In[1]: dg.meshes.square.qmesh(2)
...
IndexError: index (48) out of range (0<=index<47) in dimension 0

In [2]: debug
...
ipdb> pinfo jx
...
/usr/lib/python2.7/dist-packages/IPython/core/debugger.pyc in do_pinfo(self, arg)
    490         namespaces = [('Locals', self.curframe.f_locals),
    491                       ('Globals', self.curframe.f_globals)]
--> 492         self.shell.magic_pinfo("pinfo %s" % arg, namespaces=namespaces)
    493 
    494     def checkline(self, filename, lineno):

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

@bfroehle
Copy link
Contributor Author

Pull request in the works.

@ghost ghost assigned bfroehle Jul 18, 2012
@@ -478,19 +478,20 @@ def do_pdef(self, arg):
"""The debugger interface to magic_pdef"""
namespaces = [('Locals', self.curframe.f_locals),
('Globals', self.curframe.f_globals)]
self.shell.magic_pdef(arg, namespaces=namespaces)
self.shell.find_line_magic('pdef')(arg, namespaces=namespaces)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note that we cannot use self.shell.run_line_magic since we need to pass the namespaces parameter along.

@takluyver
Copy link
Member

Is there a convenient way to test this automatically?

@bfroehle
Copy link
Contributor Author

No idea. Clearly not a heavily used feature since it's been broken for almost 2 years...

@takluyver
Copy link
Member

I didn't even realise magic commands worked in the debugger ;-)

It looks OK to me, but I'll let someone else have a look over it.

@bfroehle
Copy link
Contributor Author

Test results for commit 4767539 merged into master
Platform: linux2

  • python2.7: OK
  • python3.2: OK (libraries not available: oct2py pymongo rpy2 wx wx.aui)

Not available for testing: python2.6

@bfroehle
Copy link
Contributor Author

(Not that any of this is actually tested by anything...)

@fperez
Copy link
Member

fperez commented Jul 20, 2012

At the very least a set of smoke tests with a toy function would catch the worst offences.

Ideally, magics meant to print output should always be written as two components: a pure function that returns a string, and the user-facing one that simply calls print. That way we can test programatically the inner one, and ignore the print one-liner tests-wise (or simply smoke-test it without worrying about trying to capture stdout).

If you want to refactor these in two each to that effect, that would be awesome. The more we pay little by little our technical debt, the better...

@fperez
Copy link
Member

fperez commented Jul 20, 2012

ps - the PR is still better than the current situation, so if you think you can't do the little refactoring step for those tests now, just add the outer smoke tests at least, which are better than nothing and trivial to do.

@bfroehle
Copy link
Contributor Author

Let's do this in two phases then, the first a simple fix for inclusion in 0.13.1 and then a bigger refactoring.

I'm looking in to how to write a test for the debugger. I think I should be able to find some examples in the CPython source.

@ghost ghost assigned bfroehle Jul 20, 2012
@bfroehle
Copy link
Contributor Author

Okay, so I've added some tests for calling pdef/pdoc/pinfo from ipdb.


def do_pinfo(self, arg):
"""The debugger equivalant of ?obj"""
namespaces = [('Locals', self.curframe.f_locals),
('Globals', self.curframe.f_globals)]
self.shell.magic_pinfo("pinfo %s" % arg, namespaces=namespaces)
self.shell.find_line_magic('pinfo')("pinfo %s" % arg,
Copy link
Member

Choose a reason for hiding this comment

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

Why did you decide to make the call this way and not with the higher-level run_line_magic method?

@fperez
Copy link
Member

fperez commented Jul 21, 2012

Code looks great, will post test_pr results soon with 604b310 and we can merge once the minor question above is clarified. thanks!

@fperez
Copy link
Member

fperez commented Jul 21, 2012

Test results for commit 604b310 merged into master
Platform: linux2

  • python2.7: OK
  • python3.2: OK (libraries not available: cython matplotlib oct2py pygments pymongo rpy2 wx wx.aui)

Not available for testing: python2.6, python3.1

@minrk
Copy link
Member

minrk commented Jul 21, 2012

@fperez he answered that above with:

Note that we cannot use self.shell.run_line_magic since we need to pass the namespaces parameter along.

bfroehle added a commit that referenced this pull request Jul 23, 2012
ipdb: Fix pdef, pdoc, pinfo commands.
@bfroehle bfroehle merged commit 2e3f3b3 into ipython:master Jul 23, 2012
@bfroehle
Copy link
Contributor Author

@minrk Are you handling cherry-picking these commits into the 0.13.1 branch?

@minrk
Copy link
Member

minrk commented Jul 23, 2012

yeah - I've been putting together a script that applies the patch from GitHub, so I (or anyone) can do python backport_pr.py 2169. The 0.13.1 branch on ipython is the result of this script so far.

@fperez
Copy link
Member

fperez commented Jul 23, 2012

Right, missed that. Thanks!

minrk added a commit that referenced this pull request Jul 27, 2012
```
In[1]: dg.meshes.square.qmesh(2)
...
IndexError: index (48) out of range (0<=index<47) in dimension 0

In [2]: debug
...
ipdb> pinfo jx
...
/usr/lib/python2.7/dist-packages/IPython/core/debugger.pyc in do_pinfo(self, arg)
    490         namespaces = [('Locals', self.curframe.f_locals),
    491                       ('Globals', self.curframe.f_globals)]
--> 492         self.shell.magic_pinfo("pinfo %s" % arg, namespaces=namespaces)
    493
    494     def checkline(self, filename, lineno):

AttributeError: 'TerminalInteractiveShell' object has no attribute 'magic_pinfo'
```
yarikoptic added a commit to yarikoptic/ipython that referenced this pull request May 2, 2014
* commit 'rel-0.13-33-gcfc5692': (33 commits)
  Backport PR ipython#2347: adjust division error message checking to account for Python 3
  Backport PR ipython#2305: RemoteError._render_traceback_ calls self.render_traceback
  Backport PR ipython#2280: fix SSH passwordless check for OpenSSH
  Backport PR ipython#2270: SSHLauncher tweaks
  Backport PR ipython#2261: Fix: longest_substr([]) -> ''
  Backport PR ipython#2250: fix html in notebook example
  Backport PR ipython#2235: remove spurious print statement from setupbase.py
  fixup
  Backport PR ipython#2223: Custom tracebacks
  Backport PR ipython#2214: use KernelApp.exec_lines/files in IPEngineApp
  Backport PR ipython#2212: catch errors in markdown javascript
  Backport PR ipython#2194: clean nan/inf in json_clean
  Backport PR ipython#2177: remove numpy install from travis/tox scripts
  Backport PR ipython#2169: ipdb: pdef, pdoc, pinfo magics all broken
  Backport PR ipython#2186: removed references to h5py dependence in octave magic documentation
  Backport PR ipython#2185: added test for %store, fixed storemagic
  Backport PR ipython#2170: Fix tab completion with IPython.embed_kernel().
  Backport PR ipython#2163: fix 'remote_profie_dir' typo in SSH launchers
  Backport PR ipython#2117: use explicit url in notebook example
  Backport PR ipython#2126: ipcluster broken with any batch (PBS/LSF/SGE)
  ...
mattvonrocketstein pushed a commit to mattvonrocketstein/ipython that referenced this pull request Nov 3, 2014
ipdb: Fix pdef, pdoc, pinfo commands.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants