gh-103068: Check condition expression of breakpoints for pdb (#103069)

Co-authored-by: Łukasz Langa <lukasz@langa.pl>
Co-authored-by: Artem Mukhin <ortem00@gmail.com>
This commit is contained in:
gaogaotiantian 2023-03-29 03:09:12 -07:00 committed by GitHub
parent d835b3f05d
commit e375bff037
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 45 additions and 13 deletions

View file

@ -240,9 +240,11 @@ def test_pdb_breakpoint_commands():
>>> with PdbTestInput([ # doctest: +NORMALIZE_WHITESPACE
... 'break 3',
... 'break 4, +',
... 'disable 1',
... 'ignore 1 10',
... 'condition 1 1 < 2',
... 'condition 1 1 <',
... 'break 4',
... 'break 4',
... 'break',
@ -264,6 +266,8 @@ def test_pdb_breakpoint_commands():
... 'commands 10', # out of range
... 'commands a', # display help
... 'commands 4', # already deleted
... 'break 6, undefined', # condition causing `NameError` during evaluation
... 'continue', # will stop, ignoring runtime error
... 'continue',
... ]):
... test_function()
@ -271,12 +275,16 @@ def test_pdb_breakpoint_commands():
-> print(1)
(Pdb) break 3
Breakpoint 1 at <doctest test.test_pdb.test_pdb_breakpoint_commands[0]>:3
(Pdb) break 4, +
*** Invalid condition +: SyntaxError: invalid syntax
(Pdb) disable 1
Disabled breakpoint 1 at <doctest test.test_pdb.test_pdb_breakpoint_commands[0]>:3
(Pdb) ignore 1 10
Will ignore next 10 crossings of breakpoint 1.
(Pdb) condition 1 1 < 2
New condition set for breakpoint 1.
(Pdb) condition 1 1 <
*** Invalid condition 1 <: SyntaxError: invalid syntax
(Pdb) break 4
Breakpoint 2 at <doctest test.test_pdb.test_pdb_breakpoint_commands[0]>:4
(Pdb) break 4
@ -331,8 +339,13 @@ def test_pdb_breakpoint_commands():
end
(Pdb) commands 4
*** cannot set commands: Breakpoint 4 already deleted
(Pdb) break 6, undefined
Breakpoint 5 at <doctest test.test_pdb.test_pdb_breakpoint_commands[0]>:6
(Pdb) continue
3
> <doctest test.test_pdb.test_pdb_breakpoint_commands[0]>(6)test_function()
-> print(4)
(Pdb) continue
4
"""
@ -597,13 +610,14 @@ def test_pdb_display_command():
... 'undisplay',
... 'display a < 1',
... 'n',
... 'display undefined',
... 'continue',
... ]):
... test_function()
> <doctest test.test_pdb.test_pdb_display_command[0]>(4)test_function()
-> a = 1
(Pdb) display +
Unable to display +: ** raised SyntaxError: invalid syntax **
*** Unable to display +: SyntaxError: invalid syntax
(Pdb) display
No expression is being displayed
(Pdb) display a
@ -627,6 +641,8 @@ def test_pdb_display_command():
(Pdb) n
> <doctest test.test_pdb.test_pdb_display_command[0]>(7)test_function()
-> a = 4
(Pdb) display undefined
display undefined: ** raised NameError: name 'undefined' is not defined **
(Pdb) continue
"""