JJMC89 created this task.
JJMC89 added a project: Pywikibot-core.
Herald added subscribers: pywikibot-bugs-list, Aklapper.

TASK DESCRIPTION

When attempting to get the redirects to a page using page.backlinks(filterRedirects=True), IsNotRedirectPage is raised. The page the exception claims is not a redirect, however, is a redirect.

page.getReferences(redirectsOnly=True) gives the same exception.

page.getReferences(follow_redirects=False, redirectsOnly=True) yields the same page twice.

Python 3.4.3 (default, Nov 28 2017, 16:41:13)
[GCC 4.8.4] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pywikibot
>>> site = pywikibot.Site('en', 'wikipedia')
>>> page = pywikibot.Page(site, 'File:1979–80 National Football League (Ireland) final.jpg')
>>> page.backlinks(filterRedirects=True)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/shared/pywikipedia/core/pywikibot/tools/__init__.py", line 1423, in wrapper
    return obj(*__args, **__kw)
  File "/shared/pywikipedia/core/pywikibot/page.py", line 1062, in backlinks
    content=content
  File "/shared/pywikipedia/core/pywikibot/site.py", line 3649, in pagebacklinks
    if redir.getRedirectTarget() == page:
  File "/shared/pywikipedia/core/pywikibot/page.py", line 1664, in getRedirectTarget
    return self.site.getredirtarget(self)
  File "/shared/pywikipedia/core/pywikibot/site.py", line 3166, in getredirtarget
    raise IsNotRedirectPage(page)
pywikibot.exceptions.IsNotRedirectPage: Page [[en:File:1979-80 National Football League (Ireland) final.jpg]] is not a redirect page.
>>> 
>>> page2 = pywikibot.Page(site, 'File:1979-80 National Football League (Ireland) final.jpg')
>>> page2.isRedirectPage()
True
>>> page2.getRedirectTarget()
Page('File:1979–80 National Football League (Ireland) final.jpg')
>>> page3 = page2.getRedirectTarget()
>>> page3
Page('File:1979–80 National Football League (Ireland) final.jpg')
>>> page == page3
True
>>> 
>>> page.getReferences(redirectsOnly=True)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/shared/pywikipedia/core/pywikibot/tools/__init__.py", line 1423, in wrapper
    return obj(*__args, **__kw)
  File "/shared/pywikipedia/core/pywikibot/page.py", line 1038, in getReferences
    content=content
  File "/shared/pywikipedia/core/pywikibot/tools/__init__.py", line 1423, in wrapper
    return obj(*__args, **__kw)
  File "/shared/pywikipedia/core/pywikibot/site.py", line 3718, in pagereferences
    namespaces=namespaces, content=content),
  File "/shared/pywikipedia/core/pywikibot/site.py", line 3649, in pagebacklinks
    if redir.getRedirectTarget() == page:
  File "/shared/pywikipedia/core/pywikibot/page.py", line 1664, in getRedirectTarget
    return self.site.getredirtarget(self)
  File "/shared/pywikipedia/core/pywikibot/site.py", line 3166, in getredirtarget
    raise IsNotRedirectPage(page)
pywikibot.exceptions.IsNotRedirectPage: Page [[en:File:1979-80 National Football League (Ireland) final.jpg]] is not a redirect page.
>>> 
>>> list(page.getReferences(follow_redirects=False, redirectsOnly=True))
[FilePage('File:1979-80 National Football League (Ireland) final.jpg'), FilePage('File:1979-80 National Football League (Ireland) final.jpg')]

Note: The difference between page and page2 is en dash vs hyphen.


TASK DETAIL
https://phabricator.wikimedia.org/T194233

EMAIL PREFERENCES
https://phabricator.wikimedia.org/settings/panel/emailpreferences/

To: JJMC89
Cc: Aklapper, pywikibot-bugs-list, JJMC89, Magul, Tbscho, MayS, Mdupont, Avicennasis, jayvdb, Dalba, Masti, Alchimista, Rxy
_______________________________________________
pywikibot-bugs mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/pywikibot-bugs

Reply via email to