Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork33.4k
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
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 ofp x + x, I want to confirm that we did stop insidefoo.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 checkbar 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.
| 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 forlinecache. It is a module globals acquired from a function, and the part matters is about the module (loader and stuff).
ee337be intopython:mainUh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
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_globalspassed in is of the current frame, andlinecacheneeds that to get the source.The correct way to deal with this is to pass in the
module_globalsof 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.