jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/337281 )
Change subject: checkimages.py: Prevent TypeError when self.num_notify is None ......................................................................
checkimages.py: Prevent TypeError when self.num_notify is None
When the max notification is not set, self.num_notify will be None instead of defaultdict, and attempting to reduce the value of an element will result in: TypeError: 'NoneType' object has no attribute '__getitem__' We check if self.num_notify is not None earlier in order to prevent this exception.
The logic of checking if the counter has ran out has also been changed from `not value` to `value == 0` for clarity.
Follow up for I9e25b35d42af3c73c581c6d05a6a4a8dc8ef62c6
Bug: T157728 Change-Id: I7d5966c52dff4b342942abe030295f3e3c1f422f --- M scripts/checkimages.py 1 file changed, 3 insertions(+), 2 deletions(-)
Approvals: jenkins-bot: Verified Xqt: Looks good to me, approved
diff --git a/scripts/checkimages.py b/scripts/checkimages.py index d4207a7..a56bd56 100755 --- a/scripts/checkimages.py +++ b/scripts/checkimages.py @@ -778,7 +778,7 @@
# Check maximum number of notifications for this talk page if (self.num_notify is not None and - not self.num_notify[self.talk_page.title()]): + self.num_notify[self.talk_page.title()] == 0): pywikibot.output('Maximum notifications reached, skip.') return
@@ -787,7 +787,8 @@ except pywikibot.LockedPage: pywikibot.output(u'Talk page blocked, skip.') else: - self.num_notify[self.talk_page.title()] -= 1 + if self.num_notify is not None: + self.num_notify[self.talk_page.title()] -= 1
if emailPageName and emailSubj: emailPage = pywikibot.Page(self.site, emailPageName)