Uh oh!
There was an error while loading. Please reload this page.
gh-60115: Support frozen modules for linecache.getline() - #131638
Conversation
gaogaotiantian
commented
Mar 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.
Just some small nits. Maybe a test with a frozen module with some content or do we have no way to do it easily?
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
commented
Mar 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
commented
Apr 2, 2025
Hey @iritkatriel , do you mind taking a quick look at this? |
iritkatriel
left a comment
There was a problem hiding this comment.
LGTM, though I wouldn't backport this.
gaogaotiantian
commented
Apr 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
commented
Apr 2, 2025
Might as well, in case someone is surprised by something. |
gaogaotiantian
commented
Apr 2, 2025
Not sure if my claim is entirely correct. There might be cases when |
iritkatriel
commented
Apr 2, 2025
I don't know. |
gaogaotiantian
commented
Apr 2, 2025
Okay I updated the documentation, which should clear things up a bit. |
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.