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):
pywikibot-commits@lists.wikimedia.org