Repository navigation
Conversation
|
Nice — I independently diagnosed the same root cause and had pushed a fix, which I just withdrew in favor of this earlier PR (#112444, closed, see comment). What my now-closed branch had that this PR might want for review completeness:
Feel free to cherry-pick/land any of those assertions in this PR, or ignore if yours already covers the same cases. Nothing behavioral differs from my read of the diff here — the eviction logic is the same one-line |
Kelton27
left a comment
There was a problem hiding this comment.
Native Windows/current-main validation:
- Base checked:
16bddc88dd325c5eef27c2cc71bbb14c16b870aaon Windows 11, Python 3.11.16. - I applied this PR's exact production change plus its two regression tests onto a disposable worktree based on that current
main. - RED on current main:
tests/plugins/test_plugin_loader.py→ 1 failed, 1 passed (module is Nonein the failed-sibling fallback case). - GREEN with the two-line eviction fix: same file → 2 passed.
- Adjacent loader coverage:
tests/plugins/test_plugin_loader.py tests/plugins/test_plugin_loader_unreadable.py→ 3 passed. ruff check plugins/plugin_loader.py tests/plugins/test_plugin_loader.py→ clean.git diff --check→ clean.
I also confirmed current main still lacks the failed-sibling eviction before applying the patch. No Windows-specific regression surfaced in this scoped validation.
Scope note: local Git networking would not fetch the contributor branch, so this validates the PR diff as shown by GitHub applied to current main, not the contributor fork's exact checkout.
dfec658 to
5015fd7
Compare
What does this PR do?
When eager loading of a plugin sibling fails, the loader previously retained its partially initialized module in
sys.modules. A later relative import then raisedImportErrorinstead of theModuleNotFoundErrorthat plugin fallbacks handle. This change removes only failed sibling entries while retaining successfully loaded siblings.Related Issue
Fixes #112096
Type of Change
Changes Made
plugins/plugin_loader.py— evict a sibling module fromsys.moduleswhen eager execution fails.tests/plugins/test_plugin_loader.py— cover the missing-module fallback and the successful sibling binding path.How to Test
scripts/run_tests.sh tests/plugins/test_plugin_loader.py -q— 2 passedruff check plugins/plugin_loader.py tests/plugins/test_plugin_loader.py— passedEvidence
assert None is not Nonebecause the cached failed sibling made the init import fail.scripts/run_tests.sh tests/plugins/test_plugin_loader.py -qreported 2 passed.module.helper.value == 42after eager loading.Review follow-up
This is a focused Python-only change. CI classifier also enables Docker and Nix for shipped Python changes; those platform/image lanes were not run locally on macOS.
Checklist
Code
Documentation & Housekeeping
cli-config.yaml.example: N/ACONTRIBUTING.mdorAGENTS.md: N/A