exceptions
— Exceptions and Warning Classes#
Pywikibot Exceptions and warning classes.
This module contains all exception and warning classes used throughout the framework:
Exception
+-- Error
+-- APIError
| +-- APIMWError
| +-- UploadError
+-- AutoblockUserError
+-- CaptchaError
+-- ClientError
| +-- Client414Error
+-- InvalidTitleError
+-- NoUsernameError
+-- PageInUseError
+-- PageRelatedError
| +-- CircularRedirectError
| +-- InterwikiRedirectPageError
| +-- IsNotRedirectPageError
| +-- IsRedirectPageError
| +-- NoMoveTargetError
| +-- NoPageError
| +-- NoRenameTargetError
| +-- NotEmailableError
| +-- PageLoadRelatedError
| | +-- InconsistentTitleError
| | +-- InvalidPageError
| | +-- NoSiteLinkError
| +-- PageSaveRelatedError
| | +-- EditConflictError
| | | +-- ArticleExistsConflictError
| | | +-- PageCreatedConflictError
| | | +-- PageDeletedConflictError
| | +-- LockedPageError
| | | +-- LockedNoPageError
| | | +-- CascadeLockedPageError
| | +-- NoCreateError
| | +-- OtherPageSaveError
| | +-- SpamblacklistError
| | +-- TitleblacklistError
| | +-- AbuseFilterDisallowedError
| +-- UnsupportedPageError
+-- SectionError
+-- ServerError
| +-- FatalServerError
| +-- Server504Error
+-- SiteDefinitionError
| +-- UnknownFamilyError
| +-- UnknownSiteError
+-- TimeoutError
| +-- MaxlagTimeoutError
+-- TranslationError
+-- UserRightsError
| +-- HiddenKeyError (KeyError)
+-- UnknownExtensionError (NotImplementedError)
+-- VersionParseError
+-- WikiBaseError
+-- CoordinateGlobeUnknownError (NotImplementedError)
+-- EntityTypeUnknownError
+-- NoWikibaseEntityError
UserWarning
+-- ArgumentDeprecationWarning (FutureWarning)
+-- FamilyMaintenanceWarning
RuntimeWarning
+-- NotImplementedWarning
Error: Base class, all exceptions should the subclass of this class.
CaptchaError: Captcha is asked and config.solve_captcha == False
ClientError: A problem with the client request
AutoblockUserError: requested action on a virtual autoblock user not valid
InvalidTitleError: Invalid page title
NoUsernameError: Username is not in user config file, or it is invalid.
PageInUseError: Page cannot be reserved due to a lock
SectionError: The section specified by # does not exist
TranslationError: no language translation found, i18n/l10n message not available
UnknownExtensionError: Extension is not defined for this site
UserRightsError: insufficient rights for requested action
VersionParseError: failed to parse version information
APIError: wiki API returned an error
APIMWError: MediaWiki internal exception
UploadError: upload failed
SiteDefinitionError: Site loading problem
UnknownSiteError: Site does not exist in Family
UnknownFamilyError: Family is not registered
PageRelatedError: any exception which is caused by an operation on a Page.
NoPageError: Page does not exist
UnsupportedPageError: Page is not supported due to a namespace restriction
IsRedirectPageError: Page is a redirect page
IsNotRedirectPageError: Page is not a redirect page
CircularRedirectError: Page is a circular redirect
InterwikiRedirectPageError: Page is a redirect to another site
InvalidPageError: Page is invalid e.g. without history
NotEmailableError: The target user has disabled email
NoMoveTargetError: An expected move target page does not exist
NoRenameTargetError: An expected rename target user does not exist
- PageLoadRelatedError: any exception which happens while loading a Page.
InconsistentTitleError: Page receives a title inconsistent with query
NoSiteLinkError: ItemPage has no sitelink to given site
PageSaveRelatedError: page exceptions within the save operation on a Page
AbuseFilterDisallowedError: AbuseFilter disallowed
SpamblacklistError: MediaWiki spam filter detected a blacklisted URL
TitleblacklistError: MediaWiki detected a blacklisted page title
OtherPageSaveError: misc. other save related exception.
- LockedPageError: Page is locked
LockedNoPageError: Title is locked against creation
CascadeLockedPageError: Page is locked due to cascading protection
- EditConflictError: Edit conflict while uploading the page
PageDeletedConflictError: Page was deleted since being retrieved
PageCreatedConflictError: Page was created by another user
ArticleExistsConflictError: Page article already exists
NoCreateError: parameter nocreate not allow page creation
ServerError: a problem with the server.
FatalServerError: A fatal/non-recoverable server error
Server414Error: Server timed out with HTTP 414 code
Server504Error: Server timed out with HTTP 504 code
WikiBaseError: any issue specific to Wikibase.
NoWikibaseEntityError: entity doesn’t exist
CoordinateGlobeUnknownError: globe is not implemented yet.
EntityTypeUnknownError: entity type is not available on the site.
TimeoutError: request failed with a timeout
MaxlagTimeoutError: request failed with a maxlag timeout
DeprecationWarning: old functionality replaced by new functionality
PendingDeprecationWarning: problematic code which has not yet been fully deprecated, possibly because a replacement is not available
RuntimeWarning: problems developers should have fixed, and users need to be aware of its status.
NotImplementedWarning: functionality not implemented
UserWarning: warnings targeted at users
config._ConfigurationDeprecationWarning: user configuration file problems
login._PasswordFileWarning: password file problems
ArgumentDeprecationWarning: command line argument problems
FamilyMaintenanceWarning: missing information in family definition
Changed in version 6.0: exceptions were renamed and are ending with “Error”.
Changed in version 7.0: All Pywikibot Error exceptions must be imported from
pywikibot.exceptions
. Deprecated exceptions identifiers were
removed.
Changed in version 8.1: Server414Error
class is deprecated; use Client414Error
instead.
- exception exceptions.APIError(code, info, **kwargs)[source]#
Bases:
Error
The wiki site returned an error message.
Save error dict returned by MW API.
- Parameters:
code (str)
info (str)
kwargs (Any)
- Return type:
None
- exception exceptions.APIMWError(mediawiki_exception_class_name, info, **kwargs)[source]#
Bases:
APIError
The API site returned an error about a MediaWiki internal exception.
Save error dict returned by MW API.
- Parameters:
mediawiki_exception_class_name (str)
info (str)
kwargs (Any)
- Return type:
None
- exception exceptions.AbuseFilterDisallowedError(page, info)[source]#
Bases:
PageSaveRelatedError
Page save failed because the AbuseFilter disallowed it.
- Parameters:
page (pywikibot.page.BasePage)
info (str)
- Return type:
None
- message = 'Edit to page {title} disallowed by the AbuseFilter.\n{info}'#
- exception exceptions.ArgumentDeprecationWarning[source]#
Bases:
UserWarning
,FutureWarning
Command line argument that is no longer supported.
- exception exceptions.ArticleExistsConflictError(page, message=None)[source]#
Bases:
EditConflictError
Page already exists.
- Parameters:
page (pywikibot.page.BasePage) – Page that caused the exception
message (str | None)
- Return type:
None
- message = 'Destination article {} already exists and is not a redirect to the source article'#
- exception exceptions.AutoblockUserError(arg)[source]#
Bases:
Error
Requested action on a virtual autoblock user not valid.
The class AutoblockUserError is an exception that is raised whenever an action is requested on a virtual autoblock user that’s not available for him (i.e. roughly everything except unblock).
- Parameters:
arg (Exception | str)
- Return type:
None
- exception exceptions.CaptchaError(arg)[source]#
Bases:
Error
Captcha is asked and config.solve_captcha == False.
- Parameters:
arg (Exception | str)
- Return type:
None
- exception exceptions.CascadeLockedPageError(page, message=None)[source]#
Bases:
LockedPageError
Page is locked due to cascading protection.
- Parameters:
page (pywikibot.page.BasePage) – Page that caused the exception
message (str | None)
- Return type:
None
- message = 'Page {} is locked due to cascading protection.'#
- exception exceptions.CircularRedirectError(page, message=None)[source]#
Bases:
PageRelatedError
Page is a circular redirect.
Exception argument is the redirect target; this may be the same title as this page or a different title (in which case the target page directly or indirectly redirects back to this one)
- Parameters:
page (pywikibot.page.BasePage) – Page that caused the exception
message (str | None)
- Return type:
None
- message = 'Page {} is a circular redirect.'#
- exception exceptions.Client414Error(arg)[source]#
Bases:
ClientError
Server returned with HTTP 414 code.
Added in version 8.1.
- Parameters:
arg (Exception | str)
- Return type:
None
- exception exceptions.ClientError(arg)[source]#
Bases:
Error
Got unexpected server response due to client issue.
Added in version 8.1.
- Parameters:
arg (Exception | str)
- Return type:
None
- exception exceptions.CoordinateGlobeUnknownError(arg)[source]#
Bases:
WikiBaseError
,NotImplementedError
This globe is not implemented yet in either WikiBase or pywikibot.
- Parameters:
arg (Exception | str)
- Return type:
None
- exception exceptions.EditConflictError(page, message=None)[source]#
Bases:
PageSaveRelatedError
There has been an edit conflict while uploading the page.
- Parameters:
page (pywikibot.page.BasePage) – Page that caused the exception
message (str | None)
- Return type:
None
- message = 'Page {} could not be saved due to an edit conflict'#
- exception exceptions.EntityTypeUnknownError(arg)[source]#
Bases:
WikiBaseError
The requested entity type is not recognised on this site.
- Parameters:
arg (Exception | str)
- Return type:
None
- exception exceptions.Error(arg)[source]#
Bases:
Exception
Pywikibot error.
- Parameters:
arg (Exception | str)
- Return type:
None
- exception exceptions.FamilyMaintenanceWarning[source]#
Bases:
UserWarning
Family class is missing definitions.
- exception exceptions.FatalServerError(arg)[source]#
Bases:
ServerError
A fatal server error will not be corrected by resending the request.
- Parameters:
arg (Exception | str)
- Return type:
None
- exception exceptions.HiddenKeyError(arg)[source]#
Bases:
UserRightsError
,KeyError
Insufficient user rights to view the hidden key.
- Parameters:
arg (Exception | str)
- Return type:
None
- exception exceptions.InconsistentTitleError(page, actual)[source]#
Bases:
PageLoadRelatedError
Page receives a title inconsistent with query.
- Parameters:
page (pywikibot.page.BasePage) – Page that caused the exception
actual (str) – title obtained by query
- Return type:
None
- exception exceptions.InterwikiRedirectPageError(page, target_page)[source]#
Bases:
PageRelatedError
Page is a redirect to another site.
This is considered invalid in Pywikibot. See bug T75184.
- Parameters:
target_page (pywikibot.page.BasePage) – Target page of the redirect.
page (pywikibot.page.BasePage)
- Return type:
None
- message = 'Page redirects to a page on another Site.\nPage: {page}\nTarget page: {target_page} on {target_site}.'#
- exception exceptions.InvalidPageError(page, message=None)[source]#
Bases:
PageLoadRelatedError
Missing page history.
Added in version 6.2.
- Parameters:
page (pywikibot.page.BasePage) – Page that caused the exception
message (str | None)
- Return type:
None
- message = 'Page {} is invalid.'#
- exception exceptions.InvalidTitleError(arg)[source]#
Bases:
Error
Invalid page title.
- Parameters:
arg (Exception | str)
- Return type:
None
- exception exceptions.IsNotRedirectPageError(page, message=None)[source]#
Bases:
PageRelatedError
Page is not a redirect page.
- Parameters:
page (pywikibot.page.BasePage) – Page that caused the exception
message (str | None)
- Return type:
None
- message = 'Page {} is not a redirect page.'#
- exception exceptions.IsRedirectPageError(page, message=None)[source]#
Bases:
PageRelatedError
Page is a redirect page.
- Parameters:
page (pywikibot.page.BasePage) – Page that caused the exception
message (str | None)
- Return type:
None
- message = 'Page {} is a redirect page.'#
- exception exceptions.LockedNoPageError(page, message=None)[source]#
Bases:
LockedPageError
Title is locked against creation.
- Parameters:
page (pywikibot.page.BasePage) – Page that caused the exception
message (str | None)
- Return type:
None
- message = 'Page {} does not exist and is locked preventing creation.'#
- exception exceptions.LockedPageError(page, message=None)[source]#
Bases:
PageSaveRelatedError
Page is locked.
- Parameters:
page (pywikibot.page.BasePage) – Page that caused the exception
message (str | None)
- Return type:
None
- message = 'Page {} is locked.'#
- exception exceptions.MaxlagTimeoutError(arg)[source]#
Bases:
TimeoutError
Request failed with a maxlag timeout error.
- Parameters:
arg (Exception | str)
- Return type:
None
- exception exceptions.NoCreateError(page, message=None)[source]#
Bases:
PageSaveRelatedError
Parameter nocreate doesn’t allow page creation.
- Parameters:
page (pywikibot.page.BasePage) – Page that caused the exception
message (str | None)
- Return type:
None
- message = 'Page {} could not be created due to parameter nocreate'#
- exception exceptions.NoMoveTargetError(page, message=None)[source]#
Bases:
PageRelatedError
Expected move target page not found.
- Parameters:
page (pywikibot.page.BasePage) – Page that caused the exception
message (str | None)
- Return type:
None
- message = 'Move target page of {} not found.'#
- exception exceptions.NoPageError(page, message=None)[source]#
Bases:
PageRelatedError
Page does not exist.
- Parameters:
page (pywikibot.page.BasePage) – Page that caused the exception
message (str | None)
- Return type:
None
- message = "Page {} doesn't exist."#
- exception exceptions.NoRenameTargetError(page, message=None)[source]#
Bases:
PageRelatedError
Expected rename target user not found.
Added in version 9.4.
- Parameters:
page (pywikibot.page.BasePage) – Page that caused the exception
message (str | None)
- Return type:
None
- message = 'Rename target user of {} not found.'#
- exception exceptions.NoSiteLinkError(page, dbname)[source]#
Bases:
PageLoadRelatedError
,NoPageError
ItemPage has no sitelink to the given site.
Added in version 8.1.
Deprecated since version 8.1:
NoPageError
dependency.- Parameters:
page (pywikibot.page.ItemPage) – ItemPage that caused the exception
dbname (str) – site identifier of the queried sitelink
- Return type:
None
- exception exceptions.NoUsernameError(arg)[source]#
Bases:
Error
Username is not in user config file (user-config.py).
- Parameters:
arg (Exception | str)
- Return type:
None
- exception exceptions.NoWikibaseEntityError(entity)[source]#
Bases:
WikiBaseError
This entity doesn’t exist.
- Parameters:
entity (pywikibot.page.WikibaseEntity) – Wikibase entity
- Return type:
None
- exception exceptions.NotEmailableError(page, message=None)[source]#
Bases:
PageRelatedError
This user is not emailable.
- Parameters:
page (pywikibot.page.BasePage) – Page that caused the exception
message (str | None)
- Return type:
None
- message = '{} is not emailable.'#
- exception exceptions.NotImplementedWarning[source]#
Bases:
_NotImplementedWarning
Feature that is no longer implemented.
- exception exceptions.OtherPageSaveError(page, reason)[source]#
Bases:
PageSaveRelatedError
Saving the page has failed due to uncatchable error.
- Parameters:
reason (str | Exception) – Details of the problem
page (pywikibot.page.BasePage)
- Return type:
None
- property args: str#
Expose args.
- message = 'Edit to page {title} failed:\n{reason}'#
- exception exceptions.PageCreatedConflictError(page, message=None)[source]#
Bases:
EditConflictError
Page was created by another user.
- Parameters:
page (pywikibot.page.BasePage) – Page that caused the exception
message (str | None)
- Return type:
None
- message = 'Page {} has been created since last retrieved.'#
- exception exceptions.PageDeletedConflictError(page, message=None)[source]#
Bases:
EditConflictError
Page was deleted since being retrieved.
- Parameters:
page (pywikibot.page.BasePage) – Page that caused the exception
message (str | None)
- Return type:
None
- message = 'Page {} has been deleted since last retrieved.'#
- exception exceptions.PageInUseError(arg)[source]#
Bases:
Error
Page cannot be reserved for writing due to existing lock.
- Parameters:
arg (Exception | str)
- Return type:
None
- exception exceptions.PageLoadRelatedError(page, message=None)[source]#
Bases:
PageRelatedError
Loading the contents of a Page object has failed.
- Parameters:
page (pywikibot.page.BasePage) – Page that caused the exception
message (str | None)
- Return type:
None
- message = 'Page {} was not loaded.'#
- exception exceptions.PageRelatedError(page, message=None)[source]#
Bases:
Error
Abstract Exception, used when the exception concerns a particular Page.
This class should be used when the Exception concerns a particular Page, and when a generic message can be written once for all.
- Parameters:
page (pywikibot.page.BasePage) – Page that caused the exception
message (str | None)
- Return type:
None
- message = ''#
- exception exceptions.PageSaveRelatedError(page, message=None)[source]#
Bases:
PageRelatedError
Saving the page has failed.
- Parameters:
page (pywikibot.page.BasePage) – Page that caused the exception
message (str | None)
- Return type:
None
- message = 'Page {} was not saved.'#
- exception exceptions.SectionError(arg)[source]#
Bases:
Error
The section specified by # does not exist.
- Parameters:
arg (Exception | str)
- Return type:
None
- exception exceptions.Server504Error(arg)[source]#
Bases:
ServerError
Server timed out with HTTP 504 code.
- Parameters:
arg (Exception | str)
- Return type:
None
- exception exceptions.ServerError(arg)[source]#
Bases:
Error
Got unexpected server response.
- Parameters:
arg (Exception | str)
- Return type:
None
- exception exceptions.SiteDefinitionError(arg)[source]#
Bases:
Error
Site does not exist.
- Parameters:
arg (Exception | str)
- Return type:
None
- exception exceptions.SpamblacklistError(page, url)[source]#
Bases:
PageSaveRelatedError
Page save failed because MediaWiki detected a blacklisted spam URL.
- Parameters:
page (pywikibot.page.BasePage)
url (str)
- Return type:
None
- message = 'Edit to page {title} rejected by spam filter due to content:\n{url}'#
- exception exceptions.TimeoutError(arg)[source]#
Bases:
Error
Request failed with a timeout error.
- Parameters:
arg (Exception | str)
- Return type:
None
- exception exceptions.TitleblacklistError(page, message=None)[source]#
Bases:
PageSaveRelatedError
Page save failed because MediaWiki detected a blacklisted page title.
- Parameters:
page (pywikibot.page.BasePage) – Page that caused the exception
message (str | None)
- Return type:
None
- message = 'Page {} is title-blacklisted.'#
- exception exceptions.TranslationError(arg)[source]#
Bases:
Error
,ImportError
Raised when no correct translation could be found.
Inherits from ImportError, as this exception is now used where previously an ImportError would have been raised, and may have been caught by scripts as such.
- Parameters:
arg (Exception | str)
- Return type:
None
- exception exceptions.UnknownExtensionError(arg)[source]#
Bases:
Error
,NotImplementedError
Extension is not defined.
- Parameters:
arg (Exception | str)
- Return type:
None
- exception exceptions.UnknownFamilyError(arg)[source]#
Bases:
SiteDefinitionError
Family is not registered.
- Parameters:
arg (Exception | str)
- Return type:
None
- exception exceptions.UnknownSiteError(arg)[source]#
Bases:
SiteDefinitionError
Site does not exist in Family.
- Parameters:
arg (Exception | str)
- Return type:
None
- exception exceptions.UnsupportedPageError(page, message=None)[source]#
Bases:
PageRelatedError
Unsupported page due to namespace restriction.
- Parameters:
page (pywikibot.page.BasePage) – Page that caused the exception
message (str | None)
- Return type:
None
- message = 'Page {} is not supported due to namespace restriction.'#
- exception exceptions.UploadError(code, message, file_key=None, offset=0)[source]#
Bases:
APIError
Upload failed with a warning message (passed as the argument).
Create a new UploadError instance.
- Parameters:
file_key (str | None) – The file_key of the uploaded file to reuse it later. If no key is known or it is an incomplete file it may be None.
offset (int | bool) – The starting offset for a chunked upload. Is False when there is no offset.
code (str)
message (str)
- Return type:
None
- property message: str#
Return warning message.
- exception exceptions.UserRightsError(arg)[source]#
Bases:
Error
Insufficient user rights to perform an action.
- Parameters:
arg (Exception | str)
- Return type:
None