-
-
Notifications
You must be signed in to change notification settings - Fork 30.7k
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
Pdb can't use the commands through -c or .pdbrc files #90095
Comments
I have a python file: def do_something():
pass
def main():
a = 1
b = 2
c = a+b
print(f"c:{c}")
pass
if __name__ == '__main__':
main() I run this command: python -m pdb -c "b 5" -c "commands 1;;do_something();;end" -c "c" main.py It doesn't work. b 5 It doesn't work either. |
Would I be able to get some clarification if this is even supposed to be possible? I myself had a desire to do this and have performed the necessary setup to make an attempt at making this possible but given the long standing stack overflow post about this, I'm not sure if this is even a bug or not. https://stackoverflow.com/questions/2013698/commands-for-breakpoints-in-a-pdbrc-file |
This is fixed now, you can define any commands/aliases in |
Just wanted to drop a quick thank you for fixing this bug that's been lurking around for ages. Huge relief to see it finally squashed! |
…ble tests (pythonGH-110496) (cherry picked from commit 44f9a84) Co-authored-by: Tian Gao <gaogaotiantian@hotmail.com>
…ble tests (pythonGH-110496) (cherry picked from commit 44f9a84) Co-authored-by: Tian Gao <gaogaotiantian@hotmail.com>
👋🏼 hello @gaogaotiantian @iritkatriel, it seems the change to fix this bug (#110496 and its backports) broke for example, a
… works fine on 3.12.2:
but the
comment lines in so this is clearly a regression. since this is a really recent (unreleased) change, i didn't bother to open a new bug report for it (which would require adding a lot of context) |
as for a fix, this seems to do to the trick: diff --git Lib/pdb.py Lib/pdb.py
index fd73f14a7e..7a9be7e5cf 100755
--- Lib/pdb.py
+++ Lib/pdb.py
@@ -297,7 +297,7 @@ def setup(self, f, tb):
self.curframe_locals = self.curframe.f_locals
if self.rcLines:
- self.cmdqueue = self.rcLines
+ self.cmdqueue = [line for line in self.rcLines if not line.lstrip().startswith("#")]
self.rcLines = []
# Override Bdb methods alternatively, actually allowing
|
Thanks. I reopened this and marked as blocker so we won't forget to fix/revert it. |
Okay this is my fault. The logic was there but somehow I ignored it. However, when I took a deeper look at this issue, it's actually more complicated. The only documentation for
So the current behavior is correct (in the way that it aligns to the documentation). If you type However, this current behavior is not desirable as there are already Oh, and this is accidentally fixed in 3.13 because we used Here are the options for 3.12:
Comments are actually easier, empty line is a totally different issue - they have meanings in In any case, we should have better documentation for |
Let's not break 3.11 and 3.12. This is not a bugfix that we would backport (it's not a bug that hurts people, while the fix might). Doc updates are fine for all versions of course. |
I'll patch 3.11 and 3.12 so the behavior is consistent as before (ignore comments and empty lines in The actual question left (if we fix docs separately) - how we deal with empty lines in |
good point about the empty lines, didn't think of that. my suggested quick fix can be easily adapted to that of course. i firmly believe they should be treated as no-op in a pdbrc file, i.e. treat them the same as comments. it's rather common to collect various snippets (e.g. copy-pasted from stack overflow) in a .pdbrc, and have empty lines between them. i think this is how it worked before, so let's not break that, similar to comment lines. |
Maybe change 3.13 too, and update the docs to match behaviour. (Doesn't seem like there's a benefit in changing this.) |
Okay I'll do a PR to keep the consistency of the behavior and update the docs (in a way that can be applied to 3.12 and 3.11 as well because no behavior is changed). |
Okay we restored the behavior for 3.12 and 3.11, and we also updated the docs to clarify the behavior of |
wow, that was quick. thanks 🙏🏼 |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
Linked PRs
.pdbrc
#116834.pdbrc
(GH-116834) #116854.pdbrc
(GH-116834) #116855The text was updated successfully, but these errors were encountered: