Xqt has submitted this change. (
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1289283?usp=email )
Change subject: [bugfix] Get default None from source instead raising
StopIteration
......................................................................
[bugfix] Get default None from source instead raising StopIteration
next(iter(source) get the next element out of source variable which
either contains one element or is empty. Multi elements leads to a
warning with suggest_help method previously.
If source is empty, next(iter(source)) raises a StopIteration except
a default value is set as second parameter.
Bug: T426730
Change-Id: I06cccda82d8c8c76d497493d35359cec54c076d9
---
M scripts/redirect.py
1 file changed, 2 insertions(+), 2 deletions(-)
Approvals:
Xqt: Verified; Looks good to me, approved
Meno25: Looks good to me, approved
diff --git a/scripts/redirect.py b/scripts/redirect.py
index 2a24e63..95a7af4 100755
--- a/scripts/redirect.py
+++ b/scripts/redirect.py
@@ -770,8 +770,8 @@
gen_options['namespaces'] = gen_factory.namespaces
gen = RedirectGenerator(action, **gen_options)
- if gen_factory.gens \
- or action != 'both' and next(iter(source)) not in ('-fullscan', '-xml'):
+ if gen_factory.gens or action != 'both' \
+ and next(iter(source), None) not in ('-fullscan', '-xml'):
gen = gen_factory.getCombinedGenerator(gen=gen)
bot = RedirectRobot(action, generator=gen, **options)
--
To view, visit
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1289283?usp=email
To unsubscribe, or for help writing mail filters, visit
https://gerrit.wikimedia.org/r/settings?usp=email
Gerrit-MessageType: merged
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: I06cccda82d8c8c76d497493d35359cec54c076d9
Gerrit-Change-Number: 1289283
Gerrit-PatchSet: 1
Gerrit-Owner: Xqt <[email protected]>
Gerrit-Reviewer: Meno25 <[email protected]>
Gerrit-Reviewer: Xqt <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
Pywikibot-commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]