bpo-36250: ignore ValueError from signal in non-main thread (GH-12251) · python/cpython@8d64bfa (original) (raw)

Original file line number Diff line number Diff line change
@@ -1333,6 +1333,35 @@ def start_pdb():
1333 1333 self.assertNotIn('Error', stdout.decode(),
1334 1334 "Got an error running test script under PDB")
1335 1335
1336 +def test_issue36250(self):
1337 +
1338 +with open(support.TESTFN, 'wb') as f:
1339 +f.write(textwrap.dedent("""
1340 + import threading
1341 + import pdb
1342 +
1343 + evt = threading.Event()
1344 +
1345 + def start_pdb():
1346 + evt.wait()
1347 + pdb.Pdb(readrc=False).set_trace()
1348 +
1349 + t = threading.Thread(target=start_pdb)
1350 + t.start()
1351 + pdb.Pdb(readrc=False).set_trace()
1352 + evt.set()
1353 + t.join()""").encode('ascii'))
1354 +cmd = [sys.executable, '-u', support.TESTFN]
1355 +proc = subprocess.Popen(cmd,
1356 +stdout=subprocess.PIPE,
1357 +stdin=subprocess.PIPE,
1358 +stderr=subprocess.STDOUT,
1359 + )
1360 +self.addCleanup(proc.stdout.close)
1361 +stdout, stderr = proc.communicate(b'cont\ncont\n')
1362 +self.assertNotIn('Error', stdout.decode(),
1363 +"Got an error running test script under PDB")
1364 +
1336 1365 def test_issue16180(self):
1337 1366 # A syntax error in the debuggee.
1338 1367 script = "def f: pass\n"