File tree Expand file tree Collapse file tree 3 files changed +38
-1
lines changed Expand file tree Collapse file tree 3 files changed +38
-1
lines changed Original file line number Diff line number Diff line change @@ -96,7 +96,7 @@ class Restart(Exception):
9696 "post_mortem" , "help" ]
9797
9898def find_function (funcname , filename ):
99- cre = re .compile (r'def\s+%s\s*[(]' % re .escape (funcname ))
99+ cre = re .compile (r'def\s+%s(\s*\[.+\])? \s*[(]' % re .escape (funcname ))
100100 try :
101101 fp = tokenize .open (filename )
102102 except OSError :
Original file line number Diff line number Diff line change @@ -352,6 +352,42 @@ def test_pdb_breakpoint_commands():
352352 4
353353 """
354354
355+ def test_pdb_breakpoint_on_annotated_function_def ():
356+ """Test breakpoints on function definitions with annotation.
357+
358+ >>> def foo[T]():
359+ ... return 0
360+
361+ >>> def bar() -> int:
362+ ... return 0
363+
364+ >>> def foobar[T]() -> int:
365+ ... return 0
366+
367+ >>> reset_Breakpoint()
368+
369+ >>> def test_function():
370+ ... import pdb; pdb.Pdb(nosigint=True, readrc=False).set_trace()
371+ ... pass
372+
373+ >>> with PdbTestInput([ # doctest: +NORMALIZE_WHITESPACE
374+ ... 'break foo',
375+ ... 'break bar',
376+ ... 'break foobar',
377+ ... 'continue',
378+ ... ]):
379+ ... test_function()
380+ > <doctest test.test_pdb.test_pdb_breakpoint_on_annotated_function_def[4]>(3)test_function()
381+ -> pass
382+ (Pdb) break foo
383+ Breakpoint 1 at <doctest test.test_pdb.test_pdb_breakpoint_on_annotated_function_def[0]>:1
384+ (Pdb) break bar
385+ Breakpoint 2 at <doctest test.test_pdb.test_pdb_breakpoint_on_annotated_function_def[1]>:1
386+ (Pdb) break foobar
387+ Breakpoint 3 at <doctest test.test_pdb.test_pdb_breakpoint_on_annotated_function_def[2]>:1
388+ (Pdb) continue
389+ """
390+
355391def test_pdb_breakpoints_preserved_across_interactive_sessions ():
356392 """Breakpoints are remembered between interactive sessions
357393
Original file line number Diff line number Diff line change 1+ Fixed the bug for :mod: `pdb ` where it can't set breakpoints on functions with certain annotations.
You can’t perform that action at this time.
0 commit comments