summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_pdb.py
diff options
context:
space:
mode:
authorTian Gao <gaogaotiantian@hotmail.com>2024-01-17 22:15:44 (GMT)
committerGitHub <noreply@github.com>2024-01-17 22:15:44 (GMT)
commit2c9cf64a3fa2b476c66eb80970e02933b7d33d05 (patch)
tree163c8d5539cfb96162f31940e0c25c190d4884f5 /Lib/test/test_pdb.py
parentc1890e666eaaa819a318b4a6b4f2c8c33a8c679e (diff)
downloadcpython-2c9cf64a3fa2b476c66eb80970e02933b7d33d05.zip
cpython-2c9cf64a3fa2b476c66eb80970e02933b7d33d05.tar.gz
cpython-2c9cf64a3fa2b476c66eb80970e02933b7d33d05.tar.bz2
[3.12] gh-112343: pdb: Use tokenize to replace convenience variables (GH-112380) (#114202)
Diffstat (limited to 'Lib/test/test_pdb.py')
-rw-r--r--Lib/test/test_pdb.py11
1 files changed, 10 insertions, 1 deletions
diff --git a/Lib/test/test_pdb.py b/Lib/test/test_pdb.py
index 08b2867..56ee6c4 100644
--- a/Lib/test/test_pdb.py
+++ b/Lib/test/test_pdb.py
@@ -389,7 +389,7 @@ def test_pdb_breakpoints_preserved_across_interactive_sessions():
1 breakpoint keep yes at ...test_pdb.py:...
2 breakpoint keep yes at ...test_pdb.py:...
(Pdb) break pdb.find_function
- Breakpoint 3 at ...pdb.py:97
+ Breakpoint 3 at ...pdb.py:...
(Pdb) break
Num Type Disp Enb Where
1 breakpoint keep yes at ...test_pdb.py:...
@@ -770,9 +770,12 @@ def test_convenience_variables():
>>> with PdbTestInput([ # doctest: +ELLIPSIS, +NORMALIZE_WHITESPACE
... '$_frame.f_lineno', # Check frame convenience variable
+ ... '$ _frame', # This should be a syntax error
... '$a = 10', # Set a convenience variable
... '$a', # Print its value
+ ... 'p "$a"', # Print the string $a
... 'p $a + 2', # Do some calculation
+ ... 'p f"$a = {$a}"', # Make sure $ in string is not converted and f-string works
... 'u', # Switch frame
... '$_frame.f_lineno', # Make sure the frame changed
... '$a', # Make sure the value persists
@@ -792,11 +795,17 @@ def test_convenience_variables():
-> try:
(Pdb) $_frame.f_lineno
3
+ (Pdb) $ _frame
+ *** SyntaxError: invalid syntax
(Pdb) $a = 10
(Pdb) $a
10
+ (Pdb) p "$a"
+ '$a'
(Pdb) p $a + 2
12
+ (Pdb) p f"$a = {$a}"
+ '$a = 10'
(Pdb) u
> <doctest test.test_pdb.test_convenience_variables[1]>(2)test_function()
-> util_function()