Skip to content

Commit 3dbba40

Browse files
committed
add test_pdb case
1 parent 960a247 commit 3dbba40

File tree

2 files changed

+25
-37
lines changed

2 files changed

+25
-37
lines changed

Lib/test/test_dis.py

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1124,43 +1124,6 @@ def test_bug_46724(self):
11241124
# Test that negative operargs are handled properly
11251125
self.do_disassembly_test(bug46724, dis_bug46724)
11261126

1127-
def test_annotate_source_locations(self):
1128-
# See gh-135700
1129-
issue_135700 = "1\nx: int"
1130-
issue_135700_class = "class A:\n 1\n x: int"
1131-
1132-
test_cases = [
1133-
("module", compile(issue_135700, "<string>", "exec").co_consts[1]),
1134-
(
1135-
"class",
1136-
compile(ast.parse(issue_135700_class), "?", "exec")
1137-
.co_consts[0]
1138-
.co_consts[1],
1139-
),
1140-
]
1141-
1142-
for case_name, annotate_code in test_cases:
1143-
with self.subTest(case=case_name):
1144-
line_starts_iterator = dis.findlinestarts(annotate_code)
1145-
valid_line_starts = [
1146-
item[0]
1147-
for item in line_starts_iterator
1148-
if item[1] is not None
1149-
] # The first item is not RESUME in class case
1150-
setup_scope_begin = valid_line_starts[0]
1151-
setup_scope_end = valid_line_starts[1]
1152-
setup_annotations_scope_positions = {
1153-
instr.positions
1154-
for instr in dis.get_instructions(annotate_code)
1155-
if setup_scope_begin <= instr.offset < setup_scope_end
1156-
and instr.positions
1157-
}
1158-
self.assertEqual(
1159-
len(setup_annotations_scope_positions),
1160-
1,
1161-
f"{case_name}: Expected uniform positions, found {len(setup_annotations_scope_positions)}: {setup_annotations_scope_positions}",
1162-
)
1163-
11641127
def test_kw_names(self):
11651128
# Test that value is displayed for keyword argument names:
11661129
self.do_disassembly_test(wrap_func_w_kwargs, dis_kw_names)

Lib/test/test_pdb.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3816,6 +3816,31 @@ def bar():
38163816
self.assertIn('-> pass', lines)
38173817
self.assertIn('(Pdb) 42', lines)
38183818

3819+
def test_issue135700(self):
3820+
"""https://github.com/python/cpython/issues/135700"""
3821+
module_code = """\
3822+
22
3823+
3824+
class ClassVar:
3825+
pass
3826+
__dataclass_fields__: ClassVar
3827+
"""
3828+
with open("testmod.py", "w") as f:
3829+
f.write(module_code)
3830+
self.addCleanup(os_helper.unlink, "testmod.py")
3831+
3832+
script = """
3833+
import testmod
3834+
print(testmod.__annotations__)
3835+
"""
3836+
commands = """
3837+
b testmod.py:1
3838+
c
3839+
c
3840+
"""
3841+
result = self.run_pdb_script(script, commands)
3842+
self.assertNotIn("(1)__annotate__()", result[0])
3843+
38193844
def test_step_into_botframe(self):
38203845
# gh-125422
38213846
# pdb should not be able to step into the botframe (bdb.py)

0 commit comments

Comments
 (0)