Closed yum-feng closed 1 year ago
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
I guess this is an issue with IPython. Can you check that you have the issue without ipdb
?
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
Same issue.
Same issue, with ipdb it raises an error,
but with pdb, it isn't,
IPython version: 8.4.0 Python version: 3.10.6 ipdb version: 0.13.9
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 Did you submit this as a pull request in the IPython repository ?
I just created one. But I do not know if my PR is submitted correctly, since this is my first PR. 🤔
Should be released in IPython 8.15
The command
l
will print the source code based on where it last left off, which is as expected. In the normalpdb
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