@@ -169,7 +169,8 @@ class PermissionsError(EditError): | |||||
We tried to do something we don't have permission to, like trying to delete | We tried to do something we don't have permission to, like trying to delete | ||||
a page as a non-admin, or trying to edit a page without login information | a page as a non-admin, or trying to edit a page without login information | ||||
and AssertEdit enabled. | |||||
and AssertEdit enabled. This will also be raised if we have been blocked | |||||
from editing. | |||||
Raised by :py:meth:`Page.edit <earwigbot.wiki.page.Page.edit>` and | Raised by :py:meth:`Page.edit <earwigbot.wiki.page.Page.edit>` and | ||||
:py:meth:`Page.add_section <earwigbot.wiki.page.Page.add_section>`. | :py:meth:`Page.add_section <earwigbot.wiki.page.Page.add_section>`. | ||||
@@ -400,6 +400,15 @@ class Page(CopyvioMixIn): | |||||
elif error.code in ["emptypage", "emptynewsection"]: | elif error.code in ["emptypage", "emptynewsection"]: | ||||
raise exceptions.NoContentError(error.info) | raise exceptions.NoContentError(error.info) | ||||
elif error.code == "blocked": | |||||
if tries > 0 or not all(self.site._login_info): | |||||
raise exceptions.PermissionsError(error.info) | |||||
else: | |||||
# Perhaps we are blocked from being logged-out? Try to log in: | |||||
self.site._login(self.site._login_info) | |||||
self._token = None # Need a new token; old one is invalid now | |||||
return self._edit(params=params, tries=1) | |||||
elif error.code == "contenttoobig": | elif error.code == "contenttoobig": | ||||
raise exceptions.ContentTooBigError(error.info) | raise exceptions.ContentTooBigError(error.info) | ||||