-
-
Notifications
You must be signed in to change notification settings - Fork 31.8k
gh-57537: Support breakpoints for zipimport modules on pdb #130290
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
gh-57537: Support breakpoints for zipimport modules on pdb #130290
Conversation
Lib/test/test_pdb.py
Outdated
'p x + x', | ||
'q' | ||
])) | ||
self.assertIn('82', stdout) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is '82'?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's the result of p x + x
, I want to confirm that we did stop inside foo.bar
. I can maybe change the testing code to use string so it's more obvious? Or I can add a comment here. The other possibility is to use a more advanced command to rule out the false positives (for example, you can't simply check bar
because it will be shown anyway).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, a string would be better.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I constructed a small piece of unique string and the assertion is close to the command - I think that made it clearer.
@@ -1134,6 +1134,7 @@ def do_break(self, arg, temporary=False): | |||
filename = None | |||
lineno = None | |||
cond = None | |||
module_globals = None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd probably call this func_globals. Up to you.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was trying to match the name for linecache. It is a module globals acquired from a function, and the part matters is about the module (loader and stuff).
Currently when pdb sets a breakpoint on a known function, it uses the filename of the code object of that specific function to locate the source. However, this does not work for zipimport modules, because the
module_globals
passed in is of the current frame, andlinecache
needs that to get the source.The correct way to deal with this is to pass in the
module_globals
of the function itself, not of the current frame. This not only solves the problem for zipimport, but also fixes other potential issues when the module of the function has its own loader.