The normal exists() is defined as:
def exists(self):
"""Return True if page exists on the wiki, even if it's a redirect.
If the title includes a section, return False if this section isn't
found.
@rtype: bool
"""
return self.site.page_exists(self)In ItemPage.exists() the code is this:
def exists(self):
"""
Determine if an entity exists in the data repository.
@rtype: bool
"""
if not hasattr(self, '_content'):
try:
self.get()
return True
except pywikibot.NoPage:
return False
return 'lastrevid' in self._contentSo if you do this on an existing item that is a redirect you'll get a nice exception. Probably easiest to just update it like this:
except pywikibot.IsRedirectPage
return TrueSome tests would be nice to verify this keeps working.