GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — Install the finder only after the module is initialized by jaraco · Pull Request #556 · python/importlib_metadata Conversation
Member
Anything walking Two conditions reach it:
The second explains why #525 wasn't reproducible: the import that fails is not the import that reports, and consumers of a backport conventionally swallow its Installing at the end of the module, rather than just after The stdlib copy is unaffected — Test
Closes #525. 🤖 Generated with Claude Code
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions`install` appended a `MetadataPathFinder` to `sys.meta_path` while the module body was still executing, 36 lines before `PathDistribution` is bound, and `PathDistribution` is the only global the installed finder has yet to see (`Prepared`, `FastPath` and `DistributionFinder` all precede it). Anything walking `sys.meta_path` in that window resolves it against incomplete globals and raises `NameError: name 'PathDistribution' is not defined`. Two conditions reach the window. Another thread calling `entry_points()` takes no module lock, as it imports nothing and only iterates `sys.meta_path`. And an import aborted in the window, as an async exception such as a signal handler or a soft time limit can do, leaves the half-built finder installed for the life of the process: the module is dropped from `sys.modules`, `install` has already deleted `PathFinder.find_distributions` so the orphan is the only provider, and even a later successful import does not displace it. Installing at the end of the module, rather than just after `PathDistribution`, states the invariant the finder depends on and so survives any later reordering. The stdlib copy is unaffected, where `install` is stripped and `PathFinder.find_distributions` imports `MetadataPathFinder` lazily. Closes #525. Co-Authored-By: Claude Opus 5 <[email protected]>
jaraco
commented
Uh oh!
There was an error while loading. Please reload this page.
jaraco
commented
Uh oh!
There was an error while loading. Please reload this page. The comment explaining why the call sits at the end of the module was four more lines for the CPython port to strip. `install` is itself removed there, so its docstring carries the constraint for free. Co-Authored-By: Claude Opus 5 <[email protected]> `install` has no counterpart in the stdlib, which reaches `MetadataPathFinder` through its own `PathFinder` and publishes no finder of its own, so the expectation belongs beside the other backport-specific tests rather than among those test_main holds for both codebases. Co-Authored-By: Claude Opus 5 <[email protected]>
jaraco
commented
Uh oh!
There was an error while loading. Please reload this page. Nothing consumes the return value now that the call is a statement, and withholding it makes the decorator form bind None rather than quietly restoring the window it was moved to close. Co-Authored-By: Claude Opus 5 <[email protected]> Uh oh!
There was an error while loading. Please reload this page.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
ReviewersNo reviewsUh oh!
There was an error while loading. Please reload this page. AssigneesNo one assignedLabels
None yet
ProjectsMilestoneNo milestoneDevelopmentSuccessfully merging this pull request may close these issues. NameError: name 'PathDistribution' is not definedUh oh!
There was an error while loading. Please reload this page. 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 01402503 — 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. |