Page MenuHomePhabricator

site.page_restrictions doesn't return the protection when a page is create protected
Open, HighPublic


site.page_restrictions() raises pywikibot.exceptions.NoPage when a page is create protected. For pages that do not exist, I would expect something like {'create': ('sysop', 'infinity')} for protected pages and {} for unprotected pages. This is already available in page._protection.

>>> site = pywikibot.Site('en', 'wikipedia')
>>> page = pywikibot.Page(site, 'Make a new page')
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "/mnt/nfs/labstore-secondary-tools-project/pywikibot/public_html/core/pywikibot/", line 1105, in protection
  File "/mnt/nfs/labstore-secondary-tools-project/pywikibot/public_html/core/pywikibot/", line 3182, in page_restrictions
    raise NoPage(page)
pywikibot.exceptions.NoPage: Page [[en:Make a new page]] doesn't exist.
>>> site.loadpageinfo(page) # if needed
>>> page._protection
{'create': ('sysop', 'infinity')}

Event Timeline

JJMC89 created this task.Jan 21 2019, 10:21 AM
Restricted Application added subscribers: pywikibot-bugs-list, Aklapper. · View Herald TranscriptJan 21 2019, 10:21 AM

page_restrictions is full of bugs, should be rewritten at all. For many protected pages it just outputs empty dict or error, not only the case you describe here

Xqt triaged this task as High priority.Jan 21 2019, 12:08 PM