-
-
Notifications
You must be signed in to change notification settings - Fork 30.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
gh-125884: Support breakpoint on functions with annotations #125892
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -363,6 +363,42 @@ def test_pdb_breakpoint_commands(): | |
4 | ||
""" | ||
|
||
def test_pdb_breakpoint_on_annotated_function_def(): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are there tests for functions with decorators? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not really. What's the expected behavior? We can't resolve the decorator in pdb, we will only add the breakpoint inside the decorated function. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Well, that's not true.. It depends on whether the function is in the name space. If it's already in the namespace, we will set the breakpoint in the decorator. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't know what the expected behaviour would be. Still interesting what the behaviour is. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So if it's not compiled, we will be searching based on source code, and we will break inside the function. If it is compiled, then the name in the name space will point to a decorated function, and the code object would be the return value of the decorator, so probably a wrapper. |
||
"""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]>(2)test_function() | ||
-> import pdb; pdb.Pdb(nosigint=True, readrc=False).set_trace() | ||
(Pdb) break foo | ||
Breakpoint 1 at <doctest test.test_pdb.test_pdb_breakpoint_on_annotated_function_def[0]>:2 | ||
(Pdb) break bar | ||
Breakpoint 2 at <doctest test.test_pdb.test_pdb_breakpoint_on_annotated_function_def[1]>:2 | ||
(Pdb) break foobar | ||
Breakpoint 3 at <doctest test.test_pdb.test_pdb_breakpoint_on_annotated_function_def[2]>:2 | ||
(Pdb) continue | ||
""" | ||
|
||
def test_pdb_commands(): | ||
"""Test the commands command of pdb. | ||
|
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure the comment is needed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Put it there as a soft assertion. If in the future somehow we failed to find the code object here, we know we had the wrong assumption before.