Skip to content

gh-75221: Search __main__ only in the executed directory or zipfile - #155256

Open
serhiy-storchaka wants to merge 1 commit into
python:mainfrom
serhiy-storchaka:gh-75221-runpy-main-search
Open

gh-75221: Search __main__ only in the executed directory or zipfile#155256
serhiy-storchaka wants to merge 1 commit into
python:mainfrom
serhiy-storchaka:gh-75221-runpy-main-search

Conversation

@serhiy-storchaka

Copy link
Copy Markdown
Member

runpy.run_path() and the execution of a directory or a zipfile searched the __main__ module in the whole sys.path, so an existing __main__ module located elsewhere could be executed instead of failing.

As a result, running Lib/test/test_runpy.py directly ran the whole test suite.

The __main__ module is now searched only in sys.path[0] -- the executed directory or zipfile.

…file

runpy.run_path() and the execution of a directory or a zipfile searched the
__main__ module in the whole sys.path, so an existing __main__ module
located elsewhere could be executed instead of failing.  As a result,
running Lib/test/test_runpy.py directly ran the whole test suite.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@read-the-docs-community

Copy link
Copy Markdown

Documentation build overview

📚 cpython-previews | 🛠️ Build #33932419 | 📁 Comparing 8ab0abb against main (4bbc20b)

  🔍 Preview build  

2 files changed
± library/runpy.html
± whatsnew/changelog.html

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