Page MenuHomePhabricator

getSitelink() method reports incorrect page when a page is not linked to Data repo.
Closed, ResolvedPublicBUG REPORT

Description

page = pywikibot.Page( pywikibot.Site('en', 'wikipedia'), 'Vodava')
page.data_item().getSitelink( pywikibot.Site('fr', 'wikipedia') )

Result is (Exception) pywikibot.exceptions.NoPageError: Page [[wikidata:Q989609]] doesn't exist

But wikidata:Q989609 does exist.

The right page to report is fr:Vodava; https://fr.wikipedia.org/wiki/Vodava

Event Timeline

matej_suchanek subscribed.

This is the source of the exception:

if site not in self.sitelinks:
    raise NoPageError(self)

The message is indeed confusing. We probably cannot change the class of the exception because of compatibility, but we can add the preferred text of the exception message as the second argument.

The right page to report is fr:Vodava; https://fr.wikipedia.org/wiki/Vodava

I disagree. How do you know the page will have that title?

Can I Work On this task ?

Yes. In fact, by assigning the task to yourself, you are claiming you will work it.

The right page to report is fr:Vodava; https://fr.wikipedia.org/wiki/Vodava

I disagree. How do you know the page will have that title?

It's not possible to programmatically know what the exact title would be in any foreign wiki.
The next best thing is to assume the title would be the same as the title of the originating page linked to current data item. If you've a better suggestion, that would be good.

Xqt triaged this task as Medium priority.Mar 31 2023, 10:43 AM
Xqt subscribed.

@Bleakprestiger are you working on it?

I think a new exception class should be used which derives from PageLoadRelatedError e.g. NoSiteLinkError. For backward compatibility it should also derive from NoPageError during a deprecation period (maybe until Pywikibot 9 or 10)

Change 904911 had a related patch set uploaded (by Ammarpad; author: Ammarpad):

[pywikibot/core@master] [IMPR] Add NoSiteLinkError for missing sitelinks

https://gerrit.wikimedia.org/r/904911

Change 904911 merged by jenkins-bot:

[pywikibot/core@master] [IMPR] Add NoSiteLinkError for missing sitelinks

https://gerrit.wikimedia.org/r/904911