GeezerVison is showing github.com — gh-126929: Retry extension loading with long Windows paths by Solaris-star · Pull Request #156759 · python/cpython
Conversation
Solaris-star
commented
Sep 1, 2026
•
edited by bedevere-app
Bot
Loading
Uh oh!
There was an error while loading. Please reload this page.
Fixes #126929.
On Windows, retry extension-module loading with a long-path-compatible DLL path when the initial load fails because the path exceeds legacy limits.
The change also adds the required Windows NEWS entry.
Validation performed:
git diff --check
- tracked-secret scan on both changed files
- commit contains DCO sign-off and an SSH signature
Windows-specific runtime validation was not available locally.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this! I hit this bug through a bazel build of a Python project on Windows. A change very similar to this one fixes it for me. A few things I noticed:
is_unc is also true for paths that already start with \\?\ or \\.\, which become \\?\UNC\?\.... So when an extension at such a path fails to load for an ordinary reason, such as the wrong architecture, the error becomes "The network path was not found" instead of the real one. For example, you can see bazel-contrib/rules_python#4071 already passes \\?\ paths, so its users would see this.
- Minor: Retrying only on
ERROR_FILENAME_EXCED_RANGE (206) would leave any other error as it is today.
- Minor: https://learn.microsoft.com/en-us/windows/win32/fileio/maximum-file-path-limitation says
\\?\ paths are "passed to the system with minimal modification, which means that you cannot use forward slashes to represent path separators, or a period to represent the current directory, or double dots to represent the parent directory." GetFullPathNameW before adding the prefix would probably be safer.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
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.