Skip to content

gh-111881: Import lazily linecache in traceback #111886

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

vstinner
Copy link
Member

@vstinner vstinner commented Nov 9, 2023

The linecache module is only used by StackSummary and FrameSummary.line property. Import the linecache module lazily to speedup Python imports and reduce the number of imports when the traceback module is imported.

The linecache module is only used by StackSummary and
FrameSummary.line property. Import the linecache module lazily to
speedup Python imports and reduce the number of imports when the
traceback module is imported.
@vstinner
Copy link
Member Author

vstinner commented Nov 9, 2023

FAIL: test_logging_at_shutdown (test.test_logging.ModuleLevelMiscTest.test_logging_at_shutdown)

It's possible to fix the test by skipping linecache in traceback during Python shutdown by catching ImportError and not providing the source code in the traceback. But currently it works, so do we need to keep this feature? It's hard to write reliable code during Python shutdown.

@vstinner
Copy link
Member Author

I lost track of this change, so I just close it.

@vstinner vstinner closed this Dec 20, 2023
@vstinner vstinner deleted the import_traceback branch December 20, 2023 10:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant