Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Lib/pdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ class Restart(Exception):
"post_mortem", "help"]

def find_function(funcname, filename):
cre = re.compile(r'def\s+%s\s*[(]' % re.escape(funcname))
cre = re.compile(r'def\s+%s(\s*\[.+\])?\s*[(]' % re.escape(funcname))
try:
fp = tokenize.open(filename)
except OSError:
Expand Down
36 changes: 36 additions & 0 deletions Lib/test/test_pdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,42 @@ def test_pdb_breakpoint_commands():
4
"""

def test_pdb_breakpoint_on_annotated_function_def():
"""Test breakpoints on function definitions with annotation.

>>> def foo[T]():
... return 0

>>> def bar() -> int:
... return 0

>>> def foobar[T]() -> int:
... return 0

>>> reset_Breakpoint()

>>> def test_function():
... import pdb; pdb.Pdb(nosigint=True, readrc=False).set_trace()
... pass

>>> with PdbTestInput([ # doctest: +NORMALIZE_WHITESPACE
... 'break foo',
... 'break bar',
... 'break foobar',
... 'continue',
... ]):
... test_function()
> <doctest test.test_pdb.test_pdb_breakpoint_on_annotated_function_def[4]>(3)test_function()
-> pass
(Pdb) break foo
Breakpoint 1 at <doctest test.test_pdb.test_pdb_breakpoint_on_annotated_function_def[0]>:1
(Pdb) break bar
Breakpoint 2 at <doctest test.test_pdb.test_pdb_breakpoint_on_annotated_function_def[1]>:1
(Pdb) break foobar
Breakpoint 3 at <doctest test.test_pdb.test_pdb_breakpoint_on_annotated_function_def[2]>:1
(Pdb) continue
"""

def test_pdb_breakpoints_preserved_across_interactive_sessions():
"""Breakpoints are remembered between interactive sessions

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixed the bug for :mod:`pdb` where it can't set breakpoints on functions with certain annotations.
Loading