jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/428944 )
Change subject: [bugfix] Don't yield duplicates with Category.articles(recurse=True) ......................................................................
[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(-)
Approvals: Zhuyifei1999: Looks good to me, but someone else must approve Framawiki: Looks good to me, approved jenkins-bot: Verified
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
pywikibot-commits@lists.wikimedia.org