Skip to content

test_signal fails when run after test_pdb: test_pdb change SIGINT handler #162300

Open

Description

@vstinner

Bug report

Example:

$ ./python -m test test_pdb test_signal -v < /dev/null
(...)
======================================================================
ERROR: test_pidfd_send_signal (test.test_signal.PidfdSignalTest.test_pidfd_send_signal)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/vstinner/python/main/Lib/test/test_signal.py", line 1479, in test_pidfd_send_signal
    signal.pidfd_send_signal(my_pidfd, signal.SIGINT)
    ~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/vstinner/python/main/Lib/bdb.py", line 291, in trace_dispatch
    return self.dispatch_opcode(frame, arg)
           ~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^
  File "/home/vstinner/python/main/Lib/bdb.py", line 415, in dispatch_opcode
    if self.quitting: raise BdbQuit
                      ^^^^^^^^^^^^^
bdb.BdbQuit

I'm working on a fix.

CPython versions tested on:

CPython main branch

Operating systems tested on:

Linux

Linked PRs

Activity

  1. self-assigned this
    on Nov 19, 2026
  2. added a commit that references this issue on Nov 20, 2026
  3. vstinner commented on Nov 20, 2026

    @vstinner
    MemberAuthor

    Python 3.14 and 3.15 are also affected. Example with my regrtest patch to detect when a signal handler is overridden (and not restored):

    $ ./python -u -m test test_pdb -v -m test_stack_entry
    (...)
    Warning -- signal_handlers was modified by test_pdb
    Warning --   Before: {<Signals.SIGINT: 2>: <built-in function default_int_handler>, <Signals.SIGTERM: 15>: <Handlers.SIG_DFL: 0>}
    Warning --   After:  {<Signals.SIGINT: 2>: <bound method Pdb.sigint_handler of <pdb.Pdb object at 0x7f77a125f340>>, <Signals.SIGTERM: 15>: <Handlers.SIG_DFL: 0>} 
    

    Moreover, in these branches, setUpPdbBackend() of test_pdb doesn't currently save the old SIGINT handler.

  4. vstinner commented on Nov 20, 2026

    @vstinner
    MemberAuthor

    I noticed this bug on iOS test suite where tests are run sequentially (in the same process) and test_signal with a bdb exception

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

testsTests in the Lib/test dirtype-bugAn unexpected behavior, bug, or error

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions