Conversation
edit_files() passed the bare editor name directly to subprocess.Popen without resolving it to a full path first. On Windows 11 some commands (e.g. the Store-app notepad redirect) only launch correctly when invoked via their absolute path, causing WinError 87 or WinError 14001. The pager code already does this correctly via _resolve_pager_command. Apply the same pattern in edit_files(): call shutil.which() on the first token of the editor command, and substitute the result when found. When shutil.which() returns None (command not on PATH), the original token is kept as-is, preserving the existing behaviour. Fixes pallets#3840
Member
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #3840.
Problem
click.edit()passes the bare editor name directly tosubprocess.Popenwithout resolving it to a full path. On Windows 11 some commands (e.g. the Store-appnotepadredirect) only launch correctly via their absolute path, causingWinError 87orWinError 14001.Fix
Call
shutil.which()on the first token of the editor command and substitute the result when found — the same pattern the pager code already uses in_resolve_pager_command. Whenshutil.which()returnsNonethe original token is kept, preserving existing behaviour.Tests
test_editor_path_normalizationto mockshutil.which(the test focuses on argument splitting, not path resolution)test_editor_resolves_command_via_which— verifies the resolved path is used asargs[0]test_editor_keeps_command_when_which_returns_none— verifies fallback when not on PATH