Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 34748cd

Browse files
committed
Fix test suite to not activate new sigint behavior in pdb.
1 parent f3fa568 commit 34748cd

3 files changed

Lines changed: 19 additions & 15 deletions

File tree

Lib/doctest.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,8 @@ class _OutputRedirectingPdb(pdb.Pdb):
318318
def __init__(self, out):
319319
self.__out = out
320320
self.__debugger_used = False
321-
pdb.Pdb.__init__(self, stdout=out)
321+
# do not play signal games in the pdb
322+
pdb.Pdb.__init__(self, stdout=out, nosigint=True)
322323
# still use input() to get user input
323324
self.use_rawinput = 1
324325

@@ -2528,14 +2529,16 @@ def debug_script(src, pm=False, globs=None):
25282529
exec(f.read(), globs, globs)
25292530
except:
25302531
print(sys.exc_info()[1])
2531-
pdb.post_mortem(sys.exc_info()[2])
2532+
p = pdb.Pdb(nosigint=True)
2533+
p.reset()
2534+
p.interaction(None, sys.exc_info()[2])
25322535
else:
25332536
fp = open(srcfilename)
25342537
try:
25352538
script = fp.read()
25362539
finally:
25372540
fp.close()
2538-
pdb.run("exec(%r)" % script, globs, globs)
2541+
pdb.Pdb(nosigint=True).run("exec(%r)" % script, globs, globs)
25392542

25402543
finally:
25412544
os.remove(srcfilename)

Lib/test/test_pdb.py

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def test_pdb_displayhook():
2929
"""This tests the custom displayhook for pdb.
3030
3131
>>> def test_function(foo, bar):
32-
... import pdb; pdb.Pdb().set_trace()
32+
... import pdb; pdb.Pdb(nosigint=True).set_trace()
3333
... pass
3434
3535
>>> with PdbTestInput([
@@ -69,7 +69,7 @@ def test_pdb_basic_commands():
6969
... return foo.upper()
7070
7171
>>> def test_function():
72-
... import pdb; pdb.Pdb().set_trace()
72+
... import pdb; pdb.Pdb(nosigint=True).set_trace()
7373
... ret = test_function_2('baz')
7474
... print(ret)
7575
@@ -168,7 +168,7 @@ def test_pdb_breakpoint_commands():
168168
"""Test basic commands related to breakpoints.
169169
170170
>>> def test_function():
171-
... import pdb; pdb.Pdb().set_trace()
171+
... import pdb; pdb.Pdb(nosigint=True).set_trace()
172172
... print(1)
173173
... print(2)
174174
... print(3)
@@ -297,7 +297,7 @@ def test_list_commands():
297297
... return foo
298298
299299
>>> def test_function():
300-
... import pdb; pdb.Pdb().set_trace()
300+
... import pdb; pdb.Pdb(nosigint=True).set_trace()
301301
... ret = test_function_2('baz')
302302
303303
>>> with PdbTestInput([ # doctest: +ELLIPSIS, +NORMALIZE_WHITESPACE
@@ -320,7 +320,7 @@ def test_list_commands():
320320
-> ret = test_function_2('baz')
321321
(Pdb) list
322322
1 def test_function():
323-
2 import pdb; pdb.Pdb().set_trace()
323+
2 import pdb; pdb.Pdb(nosigint=True).set_trace()
324324
3 -> ret = test_function_2('baz')
325325
[EOF]
326326
(Pdb) step
@@ -383,7 +383,7 @@ def test_post_mortem():
383383
... print('Exception!')
384384
385385
>>> def test_function():
386-
... import pdb; pdb.Pdb().set_trace()
386+
... import pdb; pdb.Pdb(nosigint=True).set_trace()
387387
... test_function_2()
388388
... print('Not reached.')
389389
@@ -416,7 +416,7 @@ def test_post_mortem():
416416
-> 1/0
417417
(Pdb) list
418418
1 def test_function():
419-
2 import pdb; pdb.Pdb().set_trace()
419+
2 import pdb; pdb.Pdb(nosigint=True).set_trace()
420420
3 -> test_function_2()
421421
4 print('Not reached.')
422422
[EOF]
@@ -440,7 +440,7 @@ def test_pdb_skip_modules():
440440
441441
>>> def skip_module():
442442
... import string
443-
... import pdb; pdb.Pdb(skip=['stri*']).set_trace()
443+
... import pdb; pdb.Pdb(skip=['stri*'], nosigint=True).set_trace()
444444
... string.capwords('FOO')
445445
446446
>>> with PdbTestInput([
@@ -469,7 +469,7 @@ def test_pdb_skip_modules_with_callback():
469469
>>> def skip_module():
470470
... def callback():
471471
... return None
472-
... import pdb; pdb.Pdb(skip=['module_to_skip*']).set_trace()
472+
... import pdb; pdb.Pdb(skip=['module_to_skip*'], nosigint=True).set_trace()
473473
... mod.foo_pony(callback)
474474
475475
>>> with PdbTestInput([
@@ -510,7 +510,7 @@ def test_pdb_continue_in_bottomframe():
510510
"""Test that "continue" and "next" work properly in bottom frame (issue #5294).
511511
512512
>>> def test_function():
513-
... import pdb, sys; inst = pdb.Pdb()
513+
... import pdb, sys; inst = pdb.Pdb(nosigint=True)
514514
... inst.set_trace()
515515
... inst.botframe = sys._getframe() # hackery to get the right botframe
516516
... print(1)
@@ -550,7 +550,8 @@ def test_pdb_continue_in_bottomframe():
550550

551551
def pdb_invoke(method, arg):
552552
"""Run pdb.method(arg)."""
553-
import pdb; getattr(pdb, method)(arg)
553+
import pdb
554+
getattr(pdb.Pdb(nosigint=True), method)(arg)
554555

555556

556557
def test_pdb_run_with_incorrect_argument():

Lib/test/test_zipimport_support.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ def f():
200200
pass
201201
202202
import pdb
203-
pdb.runcall(f)
203+
pdb.Pdb(nosigint=True).runcall(f)
204204
""")
205205
with temp_dir() as d:
206206
script_name = make_script(d, 'script', test_src)

0 commit comments

Comments
 (0)