jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/333298 )
Change subject: [Bugfix] Access dictionary keys safely ......................................................................
[Bugfix] Access dictionary keys safely
When there is no claim of that property, this code fails with a KeyError.
Change-Id: Ie969f583ae0c4780b44d0525d2887ec73c75ba58 --- M pywikibot/pagegenerators.py 1 file changed, 1 insertion(+), 1 deletion(-)
Approvals: Dalba: Looks good to me, approved jenkins-bot: Verified
diff --git a/pywikibot/pagegenerators.py b/pywikibot/pagegenerators.py index fc5060c..29ddced 100644 --- a/pywikibot/pagegenerators.py +++ b/pywikibot/pagegenerators.py @@ -1509,7 +1509,7 @@ if not isinstance(page, pywikibot.ItemPage): pywikibot.output(u'%s is not an ItemPage. Skipping.' % page) return False - for page_claim in page.get()['claims'][prop]: + for page_claim in page.get()['claims'].get(prop, []): if page_claim.target_equals(claim): if not qualifiers: return True
pywikibot-commits@lists.wikimedia.org