jenkins-bot has submitted this change. (
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/700439 )
Change subject: [IMPR] use a sentinel variable to determine the end of an iterable
......................................................................
[IMPR] use a sentinel variable to determine the end of an iterable
This enables None to be part of the iterables chain
Change-Id: I76e770735fc1e92fa5cd448751d3da645123760a
---
M pywikibot/tools/__init__.py
1 file changed, 4 insertions(+), 2 deletions(-)
Approvals:
Xqt: Looks good to me, approved
Matěj Suchánek: Looks good to me, but someone else must approve
jenkins-bot: Verified
diff --git a/pywikibot/tools/__init__.py b/pywikibot/tools/__init__.py
index f81ee0b..52b40ff 100644
--- a/pywikibot/tools/__init__.py
+++ b/pywikibot/tools/__init__.py
@@ -1029,9 +1029,11 @@
:return: the combined generator of iterables
:rtype: generator
"""
+ sentinel = object()
return (item
- for item in itertools.chain.from_iterable(zip_longest(*iterables))
- if item is not None)
+ for item in itertools.chain.from_iterable(
+ zip_longest(*iterables, fillvalue=sentinel))
+ if item is not sentinel)
def filter_unique(iterable, container=None, key=None, add=None):
--
To view, visit
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/700439
To unsubscribe, or for help writing mail filters, visit
https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: I76e770735fc1e92fa5cd448751d3da645123760a
Gerrit-Change-Number: 700439
Gerrit-PatchSet: 4
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Matěj Suchánek <matejsuchanek97(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged