ipdb icon indicating copy to clipboard operation
ipdb copied to clipboard

"list" syntax does not support "." as argument.

Open yum-feng opened this issue 5 years ago • 4 comments

The command l will print the source code based on where it last left off, which is as expected. In the normal pdb debugger, I would specify . as argument, l . to get back to the current line of execution.

This does not seem to work in IPDB, or am I doing something wrong ?

I'm running Python 3.6.8 with the following versions.

ipdb==0.13.3 ipython==7.14.0 ipython-genutils==0.2.0

yum-feng avatar Aug 14 '20 17:08 yum-feng

I've also run into this. It feels like a bug, because the only other way to reset list I've found is to use w to see the current line number, then use that as an argument for list

willhansen avatar Aug 26 '20 01:08 willhansen

I guess this is an issue with IPython. Can you check that you have the issue without ipdb ?

gotcha avatar Oct 01 '20 14:10 gotcha

same issue here, and confirm pdb support l . This is definitely a bug, consider l is high frequent use command, it is strange the bug still here today

wztdream avatar Sep 14 '21 16:09 wztdream

Same issue.

mzr1996 avatar Sep 16 '21 06:09 mzr1996

Same issue, with ipdb it raises an error, 2022-11-27-105741_

but with pdb, it isn't, 2022-11-27-105040_

IPython version: 8.4.0 Python version: 3.10.6 ipdb version: 0.13.9

isidroas avatar Nov 27 '22 10:11 isidroas

I found a workaround to support this. This definitely is an issue of IPython, and we can figure this out in their source code. By comparing do_list() in IPython and the function with same name in PDB, we can find the difference that in IPython code, they did not treat '.' as a valid argument. To enable the '.' argument, one can apply the following patch:

diff --git a/IPython/core/debugger.py b/IPython/core/debugger.py
index c8082e34e..5b793d783 100644
--- a/IPython/core/debugger.py
+++ b/IPython/core/debugger.py
@@ -640,7 +640,7 @@ def do_list(self, arg):
         """
         self.lastcmd = 'list'
         last = None
-        if arg:
+        if arg and arg != '.':
             try:
                 x = eval(arg, {}, {})
                 if type(x) == type(()):
@@ -655,7 +655,7 @@ def do_list(self, arg):
             except:
                 print('*** Error in argument:', repr(arg), file=self.stdout)
                 return
-        elif self.lineno is None:
+        elif self.lineno is None or arg == '.':
             first = max(1, self.curframe.f_lineno - 5)
         else:
             first = self.lineno + 1

jessie-hu-95 avatar Jul 21 '23 09:07 jessie-hu-95

@jessie-hu-95 Did you submit this as a pull request in the IPython repository ?

gotcha avatar Jul 24 '23 12:07 gotcha

I just created one. But I do not know if my PR is submitted correctly, since this is my first PR. 🤔

jessie-hu-95 avatar Jul 24 '23 14:07 jessie-hu-95

Should be released in IPython 8.15

gotcha avatar Aug 28 '23 08:08 gotcha