Skip to content

Commit ec8edbf

Browse files
authored
Merge pull request #10819 from q0w/file404
2 parents f8bd9c9 + 7f6a9ca commit ec8edbf

File tree

3 files changed

+13
-0
lines changed

3 files changed

+13
-0
lines changed

news/10812.feature.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Improve error message when ``pip config edit`` is provided an editor that
2+
doesn't exist.

src/pip/_internal/commands/configuration.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,10 @@ def open_in_editor(self, options: Values, args: List[str]) -> None:
225225

226226
try:
227227
subprocess.check_call([editor, fname])
228+
except FileNotFoundError as e:
229+
if not e.filename:
230+
e.filename = editor
231+
raise
228232
except subprocess.CalledProcessError as e:
229233
raise PipError(
230234
"Editor Subprocess exited with exit code {}".format(e.returncode)

tests/functional/test_configuration.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,3 +140,10 @@ def test_global_config_file(self, script: PipTestEnvironment) -> None:
140140
global_config_file = get_configuration_files()[kinds.GLOBAL][0]
141141
result = script.pip("config", "debug")
142142
assert f"{global_config_file}, exists:" in result.stdout
143+
144+
def test_editor_does_not_exist(self, script: PipTestEnvironment) -> None:
145+
"""Ensure that FileNotFoundError sets filename correctly"""
146+
result = script.pip(
147+
"config", "edit", "--editor", "notrealeditor", expect_error=True
148+
)
149+
assert "notrealeditor" in result.stderr

0 commit comments

Comments
 (0)