jenkins-bot submitted this change.
TextEditor.editor: Use shlex to parse editor name
Allows spaces in environment variables, e.g., `code -w`.
If `OSWIN32` is `True`, the behavior will be unchanged.
Bug: T323078
Bug: T102465
Change-Id: I31f4d4f5660cc6e6085e4494e161e1ca80876dbd
---
M pywikibot/editor.py
1 file changed, 17 insertions(+), 1 deletion(-)
diff --git a/pywikibot/editor.py b/pywikibot/editor.py
index 29e4829..9a20282 100644
--- a/pywikibot/editor.py
+++ b/pywikibot/editor.py
@@ -5,6 +5,7 @@
# Distributed under the terms of the MIT license.
#
import os
+import shlex
import subprocess
import tempfile
from pathlib import Path
@@ -83,7 +84,8 @@
command = []
# See T102465 for problems relating to using self.editor unparsed.
- command = [self.editor] + command + [file_name]
+ editor_cmd = [self.editor] if OSWIN32 else shlex.split(self.editor)
+ command = editor_cmd + command + [file_name]
pywikibot.log(f'Running editor: {self._concat(command)}')
return command
To view, visit change 926170. To unsubscribe, or for help writing mail filters, visit settings.