Skip to content

Commit cf0f79b

Browse files
committed
Improve how editors are handled in pip config
1 parent ebc13b4 commit cf0f79b

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/pip/_internal/commands/configuration.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,9 +222,13 @@ def open_in_editor(self, options: Values, args: List[str]) -> None:
222222
fname = self.configuration.get_file_to_edit()
223223
if fname is None:
224224
raise PipError("Could not determine appropriate file.")
225+
elif '"' in fname:
226+
# This shouldn't happen, unless we see a username like that.
227+
# If that happens, we'd appreciate a pull request fixing this.
228+
raise PipError('Can not open an editor for a file name containing ".')
225229

226230
try:
227-
subprocess.check_call([editor, fname])
231+
subprocess.check_call(f'{editor} "{fname}"', shell=True)
228232
except subprocess.CalledProcessError as e:
229233
raise PipError(
230234
"Editor Subprocess exited with exit code {}".format(e.returncode)

0 commit comments

Comments
 (0)