GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

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

@Solaris-star Solaris-star commented Sep 1, 2026 •
edited by bedevere-app Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

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.

  • Issue: 'ImportError: DLL load failed while importing xxxxxxx: The filename or extension is too long' with LongPathsEnabled #126929

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@Solaris-star
pythongh-126929: Retry extension loading with long Windows paths
238a0e1
Signed-off-by: Solaris-star <[email protected]>
@Solaris-star
Solaris-star requested review from FFY00 and ericsnowcurrently as code owners September 1, 2026 10:11
@bedevere-app bedevere-app Bot mentioned this pull request Sep 1, 2026
'ImportError: DLL load failed while importing xxxxxxx: The filename or extension is too long' with LongPathsEnabled #126929
Open
@bedevere-app bedevere-app Bot added the awaiting review label Sep 1, 2026
@mkanat mkanat mentioned this pull request Oct 23, 2026
MSVC: link extension modules with /MANIFEST:NO, since the embedded manifest breaks imports from long paths pypa/distutils#438
Open
mkanat
mkanat reviewed Oct 23, 2026
View reviewed changes

@mkanat mkanat left a comment

Copy link
Copy Markdown

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:

  1. 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.
  2. Minor: Retrying only on ERROR_FILENAME_EXCED_RANGE (206) would leave any other error as it is today.
  3. 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.

All reactions
@mkanat mkanat mentioned this pull request Oct 24, 2026
Windows: python.exe fails to start from a long path because of DLL manifests #160624
Open
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@ericsnowcurrently ericsnowcurrently Awaiting requested review from ericsnowcurrently ericsnowcurrently is a code owner
@FFY00 FFY00 Awaiting requested review from FFY00 FFY00 is a code owner
1 more reviewer
@mkanat mkanat mkanat left review comments
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

awaiting review

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

'ImportError: DLL load failed while importing xxxxxxx: The filename or extension is too long' with LongPathsEnabled

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@Solaris-star @mkanat
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.