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
4 changes: 3 additions & 1 deletion Lib/pdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -1487,7 +1487,9 @@ def lineinfo(self, identifier):
f = self.lookupmodule(parts[0])
if f:
fname = f
item = parts[1]
item = parts[1]
else:
return failed
answer = find_function(item, self.canonic(fname))
return answer or failed

Expand Down
16 changes: 16 additions & 0 deletions Lib/test/test_pdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -4587,6 +4587,22 @@ def bar():
]))
self.assertIn('break in bar', stdout)

def test_issue_59000(self):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are testing the wrong thing. You should test C.foo, not C.c_foo. So a good practice is to confirm that your test fails before your fix and passes after. Also from the other PR - do not test what you don't want to. Make the test minimal. C.c_foo is not important here. Let's simplify the test.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are testing the wrong thing. You should test C.foo, not C.c_foo. So a good practice is to confirm that your test fails before your fix and passes after. Also from the other PR - do not test what you don't want to. Make the test minimal. C.c_foo is not important here. Let's simplify the test.

Thank you for taking the time to review. I have made some changes.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are still testing too much. The purpose of a regression test is to test for the specific thing you fixed. When other developers read this test in the future, they should understand what is the bug back then. It's different than a feature test which needs to be comprehensive.

The only thing in this fix is that the user should not be able to set a breakpoint for C.foo if foo exists - that's the thing you should test for. All the other stuff are not related. Let's minimize the test case so it tests just this case. And by "minimize", I meant you can't delete anything anymore because every line is useful.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks again for your review! I've pared the test cases down to the minimum needed.

script = """
def foo():
pass
class C:
def foo(self):
pass
"""
commands = """
break C.foo
quit
"""
stdout, stderr = self.run_pdb_script(script, commands)
self.assertIn("The specified object 'C.foo' is not a function", stdout)


class ChecklineTests(unittest.TestCase):
def setUp(self):
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix :mod:`pdb` breakpoint resolution for class methods when the module defining the class is not imported.
Loading