This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Add listsize in pdb.py
Type: enhancement Stage: resolved
Components: Versions: Python 3.8, Python 3.7
process
Status: closed Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: matrixise, r.david.murray, rhettinger
Priority: normal Keywords: patch

Created on 2017-09-27 10:22 by matrixise, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 3787 closed matrixise, 2017-09-27 10:39
Messages (6)
msg303123 - (view) Author: Stéphane Wirtel (matrixise) * (Python committer) Date: 2017-09-27 10:22
I just added a new command for the prompt of Pdb.

(Pdb) listsize
List size: 10
(Pdb) listsize 5
List size: 5
(Pdb) listsize
List size: 5

I will publish a PR
msg303136 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2017-09-27 13:07
It isn't obvious from your description here what 'listsize' does.  I think you should have provided some more motivating details :)

Looking at your PR, this is essentially a configuration setting.  I wonder if we should think about the general problem rather than continuing to clutter the top level command namespace.  (The only current example of this I spotted in the pdb docs is display/undisplay.)
msg303138 - (view) Author: Stéphane Wirtel (matrixise) * (Python committer) Date: 2017-09-27 13:17
Hi David,

It's my fault and you are right, I didn't give the right description.

By default when you want to list the source code with pdb, you will use the list command but this one is just limited to the 10 next lines and there is no possibility to change this limit of 10 lines.

We can play with the second parameter of pdb, examples:

* list 10, 11
will show the code from the line 10 to 11

* list 10, 50
will show the code from the line 10 to 50

* list 10, 5
will show the code from the line 10 and the next 5 lines.

* list
will show from the current position and the next 10 lines.

and my first question was, why this limit exists? Could we change that?

after, I have read the doc of gdb and I have seen there was a "set linesize count" option where you can configure the number of lines to show.

Here is the reason of my proposal.

For the configuration of pdb, I am interested, I know we can use the .pdbrc file but it is really interesting if we desire to add new aliases or add new commands for the breakpoints.


Here is an other example for this issue:

./python -m pdb demo.py
 
> demo.py(1)<module>()
-> import os
(Pdb) listsize 5
List size: 5
(Pdb) l
  1  ->	import os
  2  	import sys
  3  	
  4  	def main():
  5  	    print(f"CWD: {sys.getcwd()}")
  6  	    print(f"PID: {sys.getpid()}")
(Pdb) l
  7  	
  8  	if __name__ == '__main__':
  9  	    main()
[EOF]
(Pdb)
msg303157 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2017-09-27 15:19
I don't think this is worth adding a separate command.

If some controls were needed (changing the list size has not been requested before), it may be better to follow gdb with set/get commands that could be used for other parameters as well.
msg303206 - (view) Author: Stéphane Wirtel (matrixise) * (Python committer) Date: 2017-09-28 10:03
Raymond,

+1 for the set/get commands for the parameters.

I could update my PR with your suggestions.

Stephane
msg316515 - (view) Author: Stéphane Wirtel (matrixise) * (Python committer) Date: 2018-05-14 14:58
I close this issue because I think we need to use a pair of set/get and not a new command like 'listsize'.
History
Date User Action Args
2022-04-11 14:58:52adminsetgithub: 75788
2018-05-14 14:58:26matrixisesetstatus: open -> closed

messages: + msg316515
stage: patch review -> resolved
2017-09-28 10:03:23matrixisesetmessages: + msg303206
2017-09-27 15:19:41rhettingersetnosy: + rhettinger
messages: + msg303157
2017-09-27 13:17:48matrixisesetmessages: + msg303138
2017-09-27 13:07:50r.david.murraysetnosy: + r.david.murray
messages: + msg303136
2017-09-27 10:39:22matrixisesetkeywords: + patch
stage: patch review
pull_requests: + pull_request3772
2017-09-27 10:22:08matrixisecreate