Skip to content

Commit

Permalink
Improve how editors are handled in pip config
Browse files Browse the repository at this point in the history
  • Loading branch information
pradyunsg committed Dec 8, 2021
1 parent ebc13b4 commit cf0f79b
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/pip/_internal/commands/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,9 +222,13 @@ def open_in_editor(self, options: Values, args: List[str]) -> None:
fname = self.configuration.get_file_to_edit()
if fname is None:
raise PipError("Could not determine appropriate file.")
elif '"' in fname:
# This shouldn't happen, unless we see a username like that.
# If that happens, we'd appreciate a pull request fixing this.
raise PipError('Can not open an editor for a file name containing ".')

try:
subprocess.check_call([editor, fname])
subprocess.check_call(f'{editor} "{fname}"', shell=True)
except subprocess.CalledProcessError as e:
raise PipError(
"Editor Subprocess exited with exit code {}".format(e.returncode)
Expand Down

0 comments on commit cf0f79b

Please sign in to comment.