File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -955,8 +955,15 @@ def do_continue(self, arg):
955955 Continue execution, only stop when a breakpoint is encountered.
956956 """
957957 if not self .nosigint :
958- self ._previous_sigint_handler = \
959- signal .signal (signal .SIGINT , self .sigint_handler )
958+ try :
959+ self ._previous_sigint_handler = \
960+ signal .signal (signal .SIGINT , self .sigint_handler )
961+ except ValueError :
962+ # ValueError happens when do_continue() is invoked from
963+ # a non-main thread in which case we just continue without
964+ # SIGINT set. Would printing a message here (once) make
965+ # sense?
966+ pass
960967 self .set_continue ()
961968 return 1
962969 do_c = do_cont = do_continue
Original file line number Diff line number Diff line change @@ -664,6 +664,33 @@ def bar():
664664 any ('main.py(5)foo()->None' in l for l in stdout .splitlines ()),
665665 'Fail to step into the caller after a return' )
666666
667+ def test_issue13210 (self ):
668+ # invoking "continue" on a non-main thread triggered an exception
669+ # inside signal.signal
670+
671+ with open (support .TESTFN , 'wb' ) as f :
672+ f .write (textwrap .dedent ("""
673+ import threading
674+ import pdb
675+
676+ def start_pdb():
677+ pdb.Pdb().set_trace()
678+ x = 1
679+ y = 1
680+
681+ t = threading.Thread(target=start_pdb)
682+ t.start()""" ).encode ('ascii' ))
683+ cmd = [sys .executable , '-u' , support .TESTFN ]
684+ proc = subprocess .Popen (cmd ,
685+ stdout = subprocess .PIPE ,
686+ stdin = subprocess .PIPE ,
687+ stderr = subprocess .STDOUT ,
688+ )
689+ self .addCleanup (proc .stdout .close )
690+ stdout , stderr = proc .communicate (b'cont\n ' )
691+ self .assertNotIn ('Error' , stdout .decode (),
692+ "Got an error running test script under PDB" )
693+
667694 def tearDown (self ):
668695 support .unlink (support .TESTFN )
669696
Original file line number Diff line number Diff line change @@ -175,6 +175,9 @@ Core and Builtins
175175Library
176176-------
177177
178+ - Issue #13120: Allow to call pdb.set_trace() from thread.
179+ Patch by Ilya Sandler.
180+
178181- Issue #10182: The re module doesn't truncate indices to 32 bits anymore.
179182 Patch by Serhiy Storchaka.
180183
You can’t perform that action at this time.
0 commit comments