jenkins-bot submitted this change.

View Change


Approvals: Xqt: Looks good to me, approved jenkins-bot: Verified
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.

Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: I31f4d4f5660cc6e6085e4494e161e1ca80876dbd
Gerrit-Change-Number: 926170
Gerrit-PatchSet: 3
Gerrit-Owner: ElSeiver <ellis.seiver@gmail.com>
Gerrit-Reviewer: Xqt <info@gno.de>
Gerrit-Reviewer: jenkins-bot
Gerrit-CC: Welcome, new contributor! <ssethi@wikimedia.org>
Gerrit-CC: Zoranzoki21 <zorandori4444@gmail.com>
Gerrit-MessageType: merged