Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

Merged
gaogaotiantian merged 7 commits intopython:mainfromgaogaotiantian:frozen-source
Apr 2, 2025

Conversation

@gaogaotiantian
Copy link
Member

@gaogaotiantiangaogaotiantian commentedMar 23, 2025
edited by bedevere-appbot
Loading

When we try to get source lines for frozen modules withlinecache.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_globals to get the real file and read it.

pdb suffers from it when debugging frozen modules -list deals with it but stack entry andll does not. I could fix it in pdb, but I thinklinecache could 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.

@gaogaotiantian
Copy link
MemberAuthor

Not sure if a whatsnew entry should be added for 3.14. Is this a significant enough change?

Copy link
Member

@picnixzpicnixz left a 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?

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
@gaogaotiantian
Copy link
MemberAuthor

Maybe a test with a frozen module with some content or do we have no way to do it easily?

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.

@gaogaotiantiangaogaotiantian changed the titlegh-60115: Support frozen modules for linecache.getlines()gh-60115: Support frozen modules for linecache.getline()Mar 23, 2025
@gaogaotiantian
Copy link
MemberAuthor

Hey@iritkatriel , do you mind taking a quick look at this?

Copy link
Member

@iritkatrieliritkatriel left a 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
Copy link
MemberAuthor

I don't plan to backport this. I think it's a new feature. Should we put something in the whatsnew entry?

@iritkatriel
Copy link
Member

Might as well, in case someone is surprised by something.

@gaogaotiantian
Copy link
MemberAuthor

Not sure if my claim is entirely correct. There might be cases when__file__ is not available for frozen modules?

@iritkatriel
Copy link
Member

I don't know.

@gaogaotiantian
Copy link
MemberAuthor

Okay I updated the documentation, which should clear things up a bit.

@gaogaotiantiangaogaotiantian merged commit6bd9689 intopython:mainApr 2, 2025
43 checks passed
@gaogaotiantiangaogaotiantian deleted the frozen-source branchApril 2, 2025 23:50
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@picnixzpicnixzpicnixz left review comments

@iritkatrieliritkatrieliritkatriel approved these changes

@pablogsalpablogsalAwaiting requested review from pablogsal

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

3 participants

@gaogaotiantian@iritkatriel@picnixz

[8]ページ先頭

©2009-2025 Movatter.jp