jenkins-bot merged this change.

View Change

Approvals: Zhuyifei1999: Looks good to me, but someone else must approve Framawiki: Looks good to me, approved jenkins-bot: Verified
[bugfix] Don't yield duplicates with Category.articles(recurse=True)

Bug: T137612
Change-Id: Iaafce3028455360effb6be1125885d2b3201d7d5
---
M pywikibot/page.py
1 file changed, 7 insertions(+), 0 deletions(-)

diff --git a/pywikibot/page.py b/pywikibot/page.py
index 91ee48c..33b1b64 100644
--- a/pywikibot/page.py
+++ b/pywikibot/page.py
@@ -2852,6 +2852,7 @@
(requires MW 1.18+)
@type endprefix: str
"""
+ seen = set()
for member in self.site.categorymembers(self,
namespaces=namespaces,
total=total,
@@ -2865,6 +2866,8 @@
endprefix=endprefix,
member_type=['page', 'file']
):
+ if recurse:
+ seen.add(hash(member))
yield member
if total is not None:
total -= 1
@@ -2886,6 +2889,10 @@
startprefix=startprefix,
endprefix=endprefix,
):
+ hash_value = hash(article)
+ if hash_value in seen:
+ continue
+ seen.add(hash_value)
yield article
if total is not None:
total -= 1

To view, visit change 428944. To unsubscribe, visit settings.

Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: Iaafce3028455360effb6be1125885d2b3201d7d5
Gerrit-Change-Number: 428944
Gerrit-PatchSet: 2
Gerrit-Owner: Xqt <info@gno.de>
Gerrit-Reviewer: Framawiki <framawiki@tools.wmflabs.org>
Gerrit-Reviewer: John Vandenberg <jayvdb@gmail.com>
Gerrit-Reviewer: Xqt <info@gno.de>
Gerrit-Reviewer: Zhuyifei1999 <zhuyifei1999@gmail.com>
Gerrit-Reviewer: Zoranzoki21 <zorandori4444@gmail.com>
Gerrit-Reviewer: jenkins-bot <>