jenkins-bot has submitted this change and it was merged.
Change subject: [FIX] Sensible error message when no text to add was given ......................................................................
[FIX] Sensible error message when no text to add was given
Change-Id: I86c3bd796db9d335e2a860784d7c483ca374c053 --- M scripts/add_text.py 1 file changed, 5 insertions(+), 3 deletions(-)
Approvals: Mpaa: Looks good to me, approved jenkins-bot: Verified
diff --git a/scripts/add_text.py b/scripts/add_text.py index 00c9837..77e73eb 100644 --- a/scripts/add_text.py +++ b/scripts/add_text.py @@ -341,9 +341,11 @@ else: genFactory.handleArg(arg) if textfile and not addText: - f = codecs.open(textfile, 'r', config.textfile_encoding) - addText = f.read() - f.close() + with codecs.open(textfile, 'r', config.textfile_encoding) as f: + addText = f.read() + if not addText: + pywikibot.error("The text to add wasn't given.") + return if not generator: generator = genFactory.getCombinedGenerator() if not generator:
pywikibot-commits@lists.wikimedia.org