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') >>> page.protection() Traceback (most recent call last): File "<console>", line 1, in <module> File "/mnt/nfs/labstore-secondary-tools-project/pywikibot/public_html/core/pywikibot/page.py", line 1105, in protection return self.site.page_restrictions(self) File "/mnt/nfs/labstore-secondary-tools-project/pywikibot/public_html/core/pywikibot/site.py", 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')}