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
Fix up
through generators in postmortem debugger; closes #6251
#11266
Conversation
...any updates on this? Is there something I can provide to help move this along? |
Sorry we missed the pull-request. I will have a look. Marking as 7.0 to make sure to have a look at it. |
I believe most of the debugger test are in |
Ok I was wrong for above, the only way I can see is to use subprocess and run python -i and check the output. Something similar to IPython/terminal/tests/test_embed.py I'll see if I can write a scaffold for that. |
Ok, I'm writing some test, but this seem to not be quite right:
It show frames in the wrong place (or re-go through frames it should not) I'm going to try to polish the tests framework to test that, and we can figure out what to do. I'm going to likely push this thing for 7.1 |
By passing the lowest traceback element into the debugger, we require it to use frame.f_back to find older frames. However, f_back is always None for generator frames. By providing a higher-up traceback element, pdb can traverse down the traceback.tb_next links, which do work correctly across generator calls. Furthermore, pdb will not do the right thing if it is provided with a frame/traceback pair that do not correspond to each other - it will duplicate parts of the callstack. Instead, we provide None as a frame, which will cause the debugger to start at the deepest frame, which is the desired behavior here.
Okay, I read the pdb/bdb source more carefully and force pushed what should be a real fix. Explanation in the commit message. The takeaway here for future reference is that the only place the frame passed into |
Thanks, I'll have a look, thy to commit a test framework (or at least a draft of it). |
Ok, I just pushed what should be test for this patch. It's a bit cumbersome to write, as you will see, but let's not optimize until we actually have need to write this often. |
Once test passes i'll merge. @meeseeksdev[bot] untag help wanted |
Tests are passing, let's get that in, many thanks ! |
By passing the lowest traceback element into the debugger, we require it to use frame.f_back to find older frames. However, f_back is always None for generator frames in the postmortem context. By providing a higher-up traceback element, pdb can traverse down the traceback.tb_next links, which do work correctly across generator calls.
...or at least, that's my understanding of the situation after spending half an hour researching the issue. This fix seems to work for my use cases, but I don't really understand the depths of pdb and can't tell if this may cause adverse affects elsewhere.
(I would also love to write a test for this, but I have no idea if we can or want to drive the debugger automatically for tests?)