jenkins-bot merged this change.

View Change

Approvals: Dvorapa: Looks good to me, approved jenkins-bot: Verified
[bugfix] Fix FileNotFoundError within editor.edit()

- During unittests a FileNotFoundError (WindowsError for Python 2)
occures when testing editarticle -simulate. Add shell=True for
Windows plattforms only to solve this bug.
- Also replace the dummy external editor 'call' by 'break'.
Otherwise Windows is asking for an application to open the temporary
edit file.

Bug: T128453
Change-Id: I014702c9fd0d1e725a55f5cad3a058ed54dedb97
---
M pywikibot/editor.py
M tests/utils.py
2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/pywikibot/editor.py b/pywikibot/editor.py
index 51e58d6..3b93db8 100644
--- a/pywikibot/editor.py
+++ b/pywikibot/editor.py
@@ -3,7 +3,7 @@
"""Text editor class for your favourite editor."""
#
# (C) Gerrit Holl, 2004
-# (C) Pywikibot team, 2004-2018
+# (C) Pywikibot team, 2004-2020
#
# Distributed under the terms of the MIT license.
#
@@ -14,6 +14,8 @@
import subprocess
import tempfile

+from sys import platform
+
import pywikibot

from pywikibot import config
@@ -101,7 +103,8 @@
encoding=config.editor_encoding) as tempFile:
tempFile.write(text)
creationDate = os.stat(tempFilename).st_mtime
- subprocess.call(self._command(tempFilename, text, jumpIndex))
+ cmd = self._command(tempFilename, text, jumpIndex)
+ subprocess.call(cmd, shell=platform == 'win32')
lastChangeDate = os.stat(tempFilename).st_mtime
if lastChangeDate == creationDate:
# Nothing changed
diff --git a/tests/utils.py b/tests/utils.py
index 91c55ac..89456be 100644
--- a/tests/utils.py
+++ b/tests/utils.py
@@ -629,7 +629,7 @@
str(pywikibot.config.userinterface_lang)

# Set EDITOR to an executable that ignores all arguments and does nothing.
- env[str('EDITOR')] = str('call' if OSWIN32 else 'true')
+ env[str('EDITOR')] = str('break' if OSWIN32 else 'true')
try:
p = Popen(
command, env=env, stdout=PIPE, stderr=PIPE,

To view, visit change 587708. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I014702c9fd0d1e725a55f5cad3a058ed54dedb97
Gerrit-Change-Number: 587708
Gerrit-PatchSet: 5
Gerrit-Owner: Xqt <info@gno.de>
Gerrit-Reviewer: Dvorapa <dvorapa@seznam.cz>
Gerrit-Reviewer: Xqt <info@gno.de>
Gerrit-Reviewer: jenkins-bot (75)