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
--
To view, visit
https://gerrit.wikimedia.org/r/333298
To unsubscribe, visit
https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ie969f583ae0c4780b44d0525d2887ec73c75ba58
Gerrit-PatchSet: 4
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Matěj Suchánek <matejsuchanek97(a)gmail.com>
Gerrit-Reviewer: Dalba <dalba.wiki(a)gmail.com>
Gerrit-Reviewer: Magul <tomasz.magulski(a)gmail.com>
Gerrit-Reviewer: Matěj Suchánek <matejsuchanek97(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot <>