GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-60115: Support frozen modules for linecache.getline() by gaogaotiantian · Pull Request #131638 · python/cpython

Conversation

@gaogaotiantian

@gaogaotiantian gaogaotiantian commented Mar 23, 2025 •
edited by bedevere-app Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

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 have module_globals - we can read __file__ in module_globals to get the real file and read it.

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

  • Issue: can't step through _frozen_importlib/importlib._bootstrap using pdb #60115

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@gaogaotiantian
Support getting source file for frozen modules
7bbf5d6
@gaogaotiantian
gaogaotiantian requested review from iritkatriel and pablogsal March 23, 2025 18:38
@bedevere-app bedevere-app Bot added the awaiting core review label Mar 23, 2025
@bedevere-app bedevere-app Bot mentioned this pull request Mar 23, 2025
can't step through _frozen_importlib/importlib._bootstrap using pdb #60115
Closed
@blurb-it
📜🤖 Added by blurb_it.
31387a0
@gaogaotiantian

gaogaotiantian commented Mar 23, 2025

Copy link
Copy Markdown
Member Author

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

picnixz
picnixz reviewed Mar 23, 2025
View reviewed changes

@picnixz picnixz left a comment

Copy link
Copy Markdown
Member

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?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread Misc/NEWS.d/next/Library/2025-03-23-18-39-07.gh-issue-60115.AWdcmq.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Lib/linecache.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Lib/linecache.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Lib/test/test_linecache.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

@gaogaotiantian @picnixz
Apply suggestions from code review
c101cf9
Co-authored-by: Bénédikt Tran <[email protected]>
@gaogaotiantian

gaogaotiantian commented Mar 23, 2025

Copy link
Copy Markdown
Member Author

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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@gaogaotiantian gaogaotiantian changed the title gh-60115: Support frozen modules for linecache.getlines() gh-60115: Support frozen modules for linecache.getline() Mar 23, 2025
@gaogaotiantian
Update 2025-03-23-18-39-07.gh-issue-60115.AWdcmq.rst
67505cc
picnixz
picnixz reviewed Mar 23, 2025
View reviewed changes
Comment thread Misc/NEWS.d/next/Library/2025-03-23-18-39-07.gh-issue-60115.AWdcmq.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

@gaogaotiantian

gaogaotiantian commented Apr 2, 2025

Copy link
Copy Markdown
Member Author

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

iritkatriel
iritkatriel reviewed Apr 2, 2025
View reviewed changes

@iritkatriel iritkatriel left a comment

Copy link
Copy Markdown
Member

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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@gaogaotiantian

gaogaotiantian commented Apr 2, 2025

Copy link
Copy Markdown
Member Author

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@iritkatriel

iritkatriel commented Apr 2, 2025

Copy link
Copy Markdown
Member

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@gaogaotiantian
Add whatsnew entry
381adfb
@gaogaotiantian

gaogaotiantian commented Apr 2, 2025

Copy link
Copy Markdown
Member Author

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@iritkatriel

iritkatriel commented Apr 2, 2025

Copy link
Copy Markdown
Member

I don't know.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

gaogaotiantian added 2 commits April 2, 2025 18:42
@gaogaotiantian
Update docs
188329c
@gaogaotiantian
Fix lint
bcf913b
@gaogaotiantian

gaogaotiantian commented Apr 2, 2025

Copy link
Copy Markdown
Member Author

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

iritkatriel
iritkatriel approved these changes Apr 2, 2025
View reviewed changes
@bedevere-app bedevere-app Bot added awaiting merge and removed awaiting core review labels Apr 2, 2025
@gaogaotiantian
gaogaotiantian merged commit 6bd9689 into python:main Apr 2, 2025
@gaogaotiantian
gaogaotiantian deleted the frozen-source branch April 2, 2025 23:50
@bedevere-app bedevere-app Bot removed the awaiting merge label Apr 2, 2025
@gaogaotiantian gaogaotiantian mentioned this pull request Apr 24, 2025
gh-93696: Fixed the breakpoint display error for frozen modules #132862
Merged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@picnixz picnixz picnixz left review comments
@iritkatriel iritkatriel iritkatriel approved these changes
@pablogsal pablogsal Awaiting requested review from pablogsal

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@gaogaotiantian @iritkatriel @picnixz
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.