jenkins-bot merged this change.
[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.