Skip to content

gh-141276: Avoid compiling zipimport source in get_filename#153799

Open
harjothkhara wants to merge 1 commit into
python:mainfrom
harjothkhara:codex/gh-141276-zipimport
Open

gh-141276: Avoid compiling zipimport source in get_filename#153799
harjothkhara wants to merge 1 commit into
python:mainfrom
harjothkhara:codex/gh-141276-zipimport

Conversation

@harjothkhara

@harjothkhara harjothkhara commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Summary

  • avoid compiling zipimport source while resolving a module filename
  • preserve bytecode validation and source fallback behavior
  • add a regression test and a NEWS entry

Root cause

zipimporter.get_filename() called _get_module_code(), which compiled source while import machinery was creating the module spec. Module execution then compiled the same source again.

Tests

  • ./python.exe -m test test_zipimport -m test_syntax_warning -m testBadMagic -m testBadMTime
  • ./python.exe -m test test_zipimport

Fixes #141276

Duplicate-work check

No open or merged pull request referencing #141276 was found before submission.

AI assistance

OpenAI Codex assisted with investigation, implementation, testing, and review.

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.

Syntax warnings are duplicated in zipimport

1 participant