Skip to content
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

bpo-43318: Fix a bug where pdb does not always echo cleared breakpoints. #24646

Merged
merged 11 commits into from
Jun 11, 2021

Conversation

hjzin
Copy link
Contributor

@hjzin hjzin commented Feb 25, 2021

https://bugs.python.org/issue43318

In Pdb, when successfully clear breakpoints, the Pdb should output a message:"Deleted XXX", but when breakpoints are cleared by filename:lineno, the message can't be output.

I think it's related to the following code.

pdb.py:

def do_clear(self, arg):
    ...
  
    if ':' in arg:
        # Make sure it works for "clear C:\foo\bar.py:12"
        i = arg.rfind(':')
        filename = arg[:i]
        arg = arg[i+1:]
        try:
            lineno = int(arg)
        except ValueError:
            err = "Invalid line number (%s)" % arg
        else:
            bplist = self.get_breaks(filename, lineno)
            err = self.clear_break(filename, lineno)
        if err:
            self.error(err)
        else:
            for bp in bplist:
                self.message('Deleted %s' % bp)
        return

self.get_breaks is called to get the breakpoints to be deleted, the result is in bplist. self.clear_break is called to delete the breakpoints in bplist. Each element in bplist is a reference to a Breakpoint object, so when all Breakpoint objects are removed, the bplist will become an empty list when self.clear_break is called, so pdb can't output the prompt message.

It can be simply fixed by following code:

    bplist = self.get_breaks(filename, lineno)[:]

https://bugs.python.org/issue43318

@the-knights-who-say-ni
Copy link

Hello, and thanks for your contribution!

I'm a bot set up to make sure that the project can legally accept this contribution by verifying everyone involved has signed the PSF contributor agreement (CLA).

CLA Missing

Our records indicate the following people have not signed the CLA:

@hjzin

For legal reasons we need all the people listed to sign the CLA before we can look at your contribution. Please follow the steps outlined in the CPython devguide to rectify this issue.

If you have recently signed the CLA, please wait at least one business day
before our records are updated.

You can check yourself to see if the CLA has been received.

Thanks again for the contribution, we look forward to reviewing it!

@github-actions
Copy link

This PR is stale because it has been open for 30 days with no activity.

@github-actions github-actions bot added the stale Stale PR or inactive for long period of time. label Mar 30, 2021
Lib/test/test_pdb.py Outdated Show resolved Hide resolved
@@ -0,0 +1 @@
Fix pdb can't output prompt message when breakpoints are successfully cleared by (filename, lineno).
Copy link
Member

Choose a reason for hiding this comment

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

There are two news files - this one can be deleted.

@iritkatriel
Copy link
Member

Please also resolve the merge conflict on test_pdb.py (rebase your branch).

@hjzin
Copy link
Contributor Author

hjzin commented Jun 11, 2021

Please also resolve the merge conflict on test_pdb.py (rebase your branch).

I have rebased my branch, please review again.

Lib/test/test_pdb.py Outdated Show resolved Hide resolved
@iritkatriel iritkatriel added 🔨 test-with-buildbots Test PR w/ buildbots; report in status section needs backport to 3.9 only security fixes needs backport to 3.10 only security fixes labels Jun 11, 2021
@iritkatriel iritkatriel added the type-bug An unexpected behavior, bug, or error label Jun 11, 2021
@bedevere-bot
Copy link

🤖 New build scheduled with the buildbot fleet by @iritkatriel for commit 0577eae 🤖

If you want to schedule another build, you need to add the ":hammer: test-with-buildbots" label again.

@bedevere-bot bedevere-bot removed the 🔨 test-with-buildbots Test PR w/ buildbots; report in status section label Jun 11, 2021
@iritkatriel
Copy link
Member

Thank you @hjzin . This looks good now. I will merge once the tests have run.

@iritkatriel iritkatriel changed the title bpo-43318: pdb can't output the prompt message when successfully clear breakpoints by "filename:lineno" bpo-43318: Fix a bug where pdb does not always echo cleared breakpoints. Jun 11, 2021
@iritkatriel iritkatriel added the 🔨 test-with-buildbots Test PR w/ buildbots; report in status section label Jun 11, 2021
@bedevere-bot
Copy link

🤖 New build scheduled with the buildbot fleet by @iritkatriel for commit df58705 🤖

If you want to schedule another build, you need to add the ":hammer: test-with-buildbots" label again.

@bedevere-bot bedevere-bot removed the 🔨 test-with-buildbots Test PR w/ buildbots; report in status section label Jun 11, 2021
@iritkatriel iritkatriel merged commit 4cb6ba1 into python:main Jun 11, 2021
@miss-islington
Copy link
Contributor

Thanks @hjzin for the PR, and @iritkatriel for merging it 🌮🎉.. I'm working now to backport this PR to: 3.10, 3.9.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Jun 11, 2021
@bedevere-bot
Copy link

GH-26674 is a backport of this pull request to the 3.10 branch.

@bedevere-bot bedevere-bot removed the needs backport to 3.10 only security fixes label Jun 11, 2021
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Jun 11, 2021
@bedevere-bot
Copy link

GH-26675 is a backport of this pull request to the 3.9 branch.

@bedevere-bot bedevere-bot removed the needs backport to 3.9 only security fixes label Jun 11, 2021
iritkatriel pushed a commit that referenced this pull request Jun 11, 2021
iritkatriel pushed a commit that referenced this pull request Jun 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stale Stale PR or inactive for long period of time. type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants