Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork33.7k
gh-60115: Support frozen modules for linecache.getline()#131638
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
gaogaotiantian commentedMar 23, 2025
Not sure if a whatsnew entry should be added for 3.14. Is this a significant enough change? |
picnixz left a comment
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.
Just some small nits. Maybe a test with a frozen module with some content or do we have no way to do it easily?
Misc/NEWS.d/next/Library/2025-03-23-18-39-07.gh-issue-60115.AWdcmq.rst OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
gaogaotiantian commentedMar 23, 2025
The difficult part is to get the module global of it. It's not trivial to get the frame of a frozen module in linecache tests. However, after this, I'll polish pdb and I'll add more tests there to cover the real case. It's much easier (and practical) to do it in pdb. |
Uh oh!
There was an error while loading.Please reload this page.
gaogaotiantian commentedApr 2, 2025
Hey@iritkatriel , do you mind taking a quick look at this? |
iritkatriel left a comment
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.
LGTM, though I wouldn't backport this.
gaogaotiantian commentedApr 2, 2025
I don't plan to backport this. I think it's a new feature. Should we put something in the whatsnew entry? |
iritkatriel commentedApr 2, 2025
Might as well, in case someone is surprised by something. |
gaogaotiantian commentedApr 2, 2025
Not sure if my claim is entirely correct. There might be cases when |
iritkatriel commentedApr 2, 2025
I don't know. |
gaogaotiantian commentedApr 2, 2025
Okay I updated the documentation, which should clear things up a bit. |
6bd9689 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.
When we try to get source lines for frozen modules with
linecache.getlines(), it will be rejected because frozen modules have file names starting with<. However, we can deal with that case, if we havemodule_globals- we can read__file__inmodule_globalsto get the real file and read it.pdbsuffers from it when debugging frozen modules -listdeals with it but stack entry andlldoes not. I could fix it in pdb, but I thinklinecachecould benefit from this change so it helps all users. This is also a pretty straighforward change, just convert the filename passed in to the actual file name and the rest is the same.