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
Conversation
bfroehle
commented
Jul 18, 2012
Pull request in the works. |
@@ -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) |
There was a problem hiding this comment.
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.
Is there a convenient way to test this automatically? |
No idea. Clearly not a heavily used feature since it's been broken for almost 2 years... |
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. |
Test results for commit 4767539 merged into master
Not available for testing: python2.6 |
(Not that any of this is actually tested by anything...) |
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... |
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. |
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. |
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, |
There was a problem hiding this comment.
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?
Code looks great, will post test_pr results soon with 604b310 and we can merge once the minor question above is clarified. thanks! |
Test results for commit 604b310 merged into master
Not available for testing: python2.6, python3.1 |
@fperez he answered that above with:
|
ipdb: Fix pdef, pdoc, pinfo commands.
@minrk Are you handling cherry-picking these commits into the 0.13.1 branch? |
yeah - I've been putting together a script that applies the patch from GitHub, so I (or anyone) can do |
Right, missed that. Thanks! |
``` 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' ```
* 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) ...
ipdb: Fix pdef, pdoc, pinfo commands.