Page MenuHomePhabricator

Redirect error messages don't specify the pages
Closed, InvalidPublic

Description

When I call Page.get() on a redirect in the hope that I can get the redirect target (as promised by that documentation), I instead get a version of the error message with no page ever substituted in.

For instance, instead of Page Foo is a redirect page., I always get Page %s is a redirect page..

Event Timeline

APerson created this task.Jun 26 2016, 4:06 AM
Restricted Application added subscribers: pywikibot-bugs-list, Zppix, Aklapper. · View Herald TranscriptJun 26 2016, 4:06 AM
Mpaa added a subscriber: Mpaa.Jun 26 2016, 5:44 PM

IMO, it behaves as promised.
It doesn't say you will get the redirect target, it says you'll get an exception if page is a redirect.
Unless you specify get_redirect=True, which will give you the wikitext of page.

>>> import pywikibot
>>> site = pywikibot.Site('en', 'wikisource')
>>> page = pywikibot.Page(site, 'Author:Richard Lugar)  # a redirect
>>> page.get()
...
pywikibot.exceptions.IsRedirectPage: Page [[en:Author:Richard Lugar]] is a redirect page.

>>> page.get(get_redirect=True)
'#REDIRECT [[Author:Richard Green Lugar]]'

@Mpaa, in the example you provided, the %s was replaced by an actual page title. The bug I hope to address is that whenever I do it, the replacement doesn't happen and I get Page %s is a redirect page. instead of, say, Page [[en:Author:Richard Lugar]] is a redirect page..

Mpaa added a comment.EditedJun 28 2016, 8:21 PM

I got that. But I am unable to reproduce your error.
Post the command you give when you get the error or share something that will allow others to reproduce it.

Works for me too, unable to reproduce this.
What version of pywikibot/python is this in ?

Framawiki closed this task as Invalid.Apr 25 2017, 10:44 PM
Framawiki added a subscriber: Framawiki.

Works well for me too. @APerson Please post the result of python pwb.py version if the bug is still present.