Skip to content

Pdb "commands" command with no bpnumber should use last available breakpoint #142834

Description

@cocolato

Bug report

Bug description:

According to the documentation:

With no bpnumber argument, commands refers to the last breakpoint set.

I think the intended meaning should be the last available breakpoint. However, when using the commands command without specifying a breakpoint number, if the most recently created breakpoint has been deleted, the current behavior throws an error stating "Breakpoint N already deleted".

main.py:

foo = 1
bar = 2
➜ ./python -m pdb main.py
> /cpython/main.py(2)<module>()
-> foo = 1
(Pdb) b 3    
Breakpoint 1 at /cpython/main.py:3
(Pdb) b 2
Breakpoint 2 at /cpython/main.py:2
(Pdb) clear 2
Deleted breakpoint 2 at /cpython/main.py:2
(Pdb) commands # should set command on breakpoint 1
*** cannot set commands: Breakpoint 2 already deleted

CPython versions tested on:

CPython main branch

Operating systems tested on:

Linux

Linked PRs

Activity

  1. johnslavik commented on Dec 16, 2025

    @johnslavik
    Member
  2. added
    stdlibStandard Library Python modules in the Lib/ directory
    on Dec 16, 2025
  3. johnslavik commented on Dec 16, 2025

    @johnslavik
    Member

    Good idea! Should it really be the last available breakpoint, or the last enabled breakpoint?

  4. johnslavik commented on Dec 17, 2025

    @johnslavik
    Member

    Should it really be the last available breakpoint, or the last enabled breakpoint?

    cc @gaogaotiantian

  5. gaogaotiantian commented on Dec 17, 2025

    @gaogaotiantian
    Member

    Should it really be the last available breakpoint, or the last enabled breakpoint?

    I think it should be the last available breakpoint because it's totally valid to set commands on a disabled breakpoint. However, this is a very rare case already. I believe commands is used mostly either immediately after breakpoint, or explicitly on a numbered breakpoint. This specific difference won't be noticable to the majority of the users.

  6. added a commit that references this issue on Dec 20, 2025
  7. added a commit that references this issue on Dec 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    stdlibStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions