-
-
Notifications
You must be signed in to change notification settings - Fork 32.5k
Closed
Closed
Copy link
Labels
type-featureA feature request or enhancementA feature request or enhancement
Description
Feature or enhancement
Proposal:
I propose to add a commands
argument to pdb.set_trace
and pdb.Pdb.set_trace
. The commands
fed should be a list of pdb commands that will be executed the first time the debugger is brought up - it's very similar to .pdbrc
.
import pdb
def f():
x = 1
# should print 1 and continue
pdb.set_trace(commands=['p x', 'c'])
f()
There are many use cases
- Some users use
.pdbrc
as debugging scripts, and sometimes it's not the best way because that would be the same for the whole directory. Being able to feed pdb commands can save user a lot of time re-typing all the commands after they try some fix. - It would be much easier to serve a repro regarding pdb on a silver platter. When user reports bugs about pdb, they had to give both the source code, and the commands they use to trigger the bug. With this command, the user can provide a simple one-piece script for the minimal repro.
- For cases where
stdin
is not available, or not super convenient, this could help. For example, in testing. Also, I talked withpyodide
maintainer about supportingpdb
on webbrowser, and one of the issue was the lack ofstdin
. They successfully made it work with some workaround, but this could help the case. - It's useful for remote help. It's not uncommon that a more senior developer needs to help a newbee remotely. They could send a fully ready piece of code that contains the command and ask the person to simply put it in and get the result.
This feature is also trivial to implement and easy to maintain - all the pieces are already there.
Has this already been discussed elsewhere?
This is a minor feature, which does not need previous discussion elsewhere
Links to previous discussion of this feature:
No response
Linked PRs
tanloong
Metadata
Metadata
Assignees
Labels
type-featureA feature request or enhancementA feature request or enhancement