jenkins-bot submitted this change.
Correct terminology around NoSiteLinkError
Sitelinks are unique per wiki, not necessarily by language.
Change-Id: I315a62a51e1b035ac6be97e6267e998f3ffc6f98
---
M pywikibot/exceptions.py
M pywikibot/page/_wikibase.py
2 files changed, 21 insertions(+), 7 deletions(-)
diff --git a/pywikibot/exceptions.py b/pywikibot/exceptions.py
index cfe4601..e5c1a6a 100644
--- a/pywikibot/exceptions.py
+++ b/pywikibot/exceptions.py
@@ -107,7 +107,7 @@
PageLoadRelatedError: any exception which happens while loading a Page.
- InconsistentTitleError: Page receives a title inconsistent with query
- - NoSiteLinkError: ItemPage has no sitelink to given language
+ - NoSiteLinkError: ItemPage has no sitelink to given site
PageSaveRelatedError: page exceptions within the save operation on a Page
@@ -400,21 +400,21 @@
class NoSiteLinkError(PageLoadRelatedError, NoPageError):
- """ItemPage has no sitelink to the given language.
+ """ItemPage has no sitelink to the given site.
.. versionadded:: 8.1
.. deprecated:: 8.1
:exc:`NoPageError` dependency.
"""
- def __init__(self, page: 'pywikibot.page.ItemPage', lang: str) -> None:
+ def __init__(self, page: 'pywikibot.page.ItemPage', dbname: str) -> None:
"""Initializer.
:param page: ItemPage that caused the exception
- :param lang: language code of the queried sitelink
+ :param dbname: site identifier of the queried sitelink
"""
- self.message = f'Item {{}} has no sitelink to language {lang!r}'
+ self.message = f'Item {{}} has no sitelink to {dbname!r}'
super().__init__(page)
diff --git a/pywikibot/page/_wikibase.py b/pywikibot/page/_wikibase.py
index d7e9f5c..2083a3c 100644
--- a/pywikibot/page/_wikibase.py
+++ b/pywikibot/page/_wikibase.py
@@ -1078,7 +1078,8 @@
def getSitelink(self, site, force: bool = False) -> str:
"""Return the title for the specific site.
- If the item doesn't have that language, raise NoSiteLinkError.
+ If the item doesn't have a link to that site, raise
+ NoSiteLinkError.
.. versionchanged:: 8.1
raises NoSiteLinkError instead of NoPageError.
@@ -1095,7 +1096,9 @@
self.get(force=force)
if site not in self.sitelinks:
- raise NoSiteLinkError(self, site.lang)
+ if not isinstance(site, str):
+ site = site.dbName()
+ raise NoSiteLinkError(self, site)
return self.sitelinks[site].canonical_title()
To view, visit change 926808. To unsubscribe, or for help writing mail filters, visit settings.