jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/342474 )
Change subject: Raise exception when CosmeticChangesToolkit gets no namespace ......................................................................
Raise exception when CosmeticChangesToolkit gets no namespace
self.talkpage = self.namespace >= 0 and self.namespace % 2 == 1 raises an exception anyway, so let's raise a more descriptive one.
Change-Id: Id22053956bcf7b7454c722fdda4043d116d51d2a --- M pywikibot/cosmetic_changes.py 1 file changed, 4 insertions(+), 1 deletion(-)
Approvals: jenkins-bot: Verified Xqt: Looks good to me, approved
diff --git a/pywikibot/cosmetic_changes.py b/pywikibot/cosmetic_changes.py index f1923a8..b5bc6db 100755 --- a/pywikibot/cosmetic_changes.py +++ b/pywikibot/cosmetic_changes.py @@ -206,7 +206,10 @@ self.site = site self.diff = diff self.redirect = redirect - self.namespace = namespace + try: + self.namespace = self.site.namespaces.resolve(namespace).pop(0) + except (KeyError, TypeError, IndexError): + raise ValueError('%s needs a valid namespace' % self.__class__.__name__) self.template = (self.namespace == 10) self.talkpage = self.namespace >= 0 and self.namespace % 2 == 1 self.title = pageTitle
pywikibot-commits@lists.wikimedia.org