cpython: 678dba60c12d (original) (raw)
Mercurial > cpython
changeset 80722:678dba60c12d 3.3
Merge issue #13120: Allow to call pdb.set_trace() from thread. Patch by Ilya Sandler. [#13120]
Andrew Svetlov andrew.svetlov@gmail.com | |
---|---|
date | Tue, 04 Dec 2012 21:10:20 +0200 |
parents | 6f8b5336beae(current diff)708586792eec(diff) |
children | 4006c4ca0c1f 4e5c690e7f99 |
files | Lib/pdb.py Lib/test/test_pdb.py Misc/NEWS |
diffstat | 3 files changed, 39 insertions(+), 2 deletions(-)[+] [-] Lib/pdb.py 11 Lib/test/test_pdb.py 27 Misc/NEWS 3 |
line wrap: on
line diff
--- a/Lib/pdb.py +++ b/Lib/pdb.py @@ -1031,8 +1031,15 @@ class Pdb(bdb.Bdb, cmd.Cmd): Continue execution, only stop when a breakpoint is encountered. """ if not self.nosigint:
self._previous_sigint_handler = \[](#l1.7)
signal.signal(signal.SIGINT, self.sigint_handler)[](#l1.8)
try:[](#l1.9)
self._previous_sigint_handler = \[](#l1.10)
signal.signal(signal.SIGINT, self.sigint_handler)[](#l1.11)
except ValueError:[](#l1.12)
# ValueError happens when do_continue() is invoked from[](#l1.13)
# a non-main thread in which case we just continue without[](#l1.14)
# SIGINT set. Would printing a message here (once) make[](#l1.15)
# sense?[](#l1.16)
do_c = do_cont = do_continuepass[](#l1.17) self.set_continue()[](#l1.18) return 1[](#l1.19)
--- a/Lib/test/test_pdb.py +++ b/Lib/test/test_pdb.py @@ -667,6 +667,33 @@ class PdbTestCase(unittest.TestCase): any('main.py(5)foo()->None' in l for l in stdout.splitlines()), 'Fail to step into the caller after a return')
- def test_issue13210(self):
# invoking "continue" on a non-main thread triggered an exception[](#l2.8)
# inside signal.signal[](#l2.9)
with open(support.TESTFN, 'wb') as f:[](#l2.11)
f.write(textwrap.dedent("""[](#l2.12)
import threading[](#l2.13)
import pdb[](#l2.14)
def start_pdb():[](#l2.16)
pdb.Pdb().set_trace()[](#l2.17)
x = 1[](#l2.18)
y = 1[](#l2.19)
t = threading.Thread(target=start_pdb)[](#l2.21)
t.start()""").encode('ascii'))[](#l2.22)
cmd = [sys.executable, '-u', support.TESTFN][](#l2.23)
proc = subprocess.Popen(cmd,[](#l2.24)
stdout=subprocess.PIPE,[](#l2.25)
stdin=subprocess.PIPE,[](#l2.26)
stderr=subprocess.STDOUT,[](#l2.27)
)[](#l2.28)
self.addCleanup(proc.stdout.close)[](#l2.29)
stdout, stderr = proc.communicate(b'cont\n')[](#l2.30)
self.assertNotIn('Error', stdout.decode(),[](#l2.31)
"Got an error running test script under PDB")[](#l2.32)
+ def tearDown(self): support.unlink(support.TESTFN)
--- a/Misc/NEWS +++ b/Misc/NEWS @@ -104,6 +104,9 @@ Core and Builtins Library ------- +- Issue #13120: Allow to call pdb.set_trace() from thread.