I file here two bugs because they are closely connected. The whole process of handling the data should be revised. Involved methods are at least (others may be):
get() save() exists() has_content()
delete() seems to work well.
Steps to replicate the issue:
>>> page = pywikibot.Page(site, 'Teszt') # It does not exist at his point >>> # Now I create [[Teszt]] manually ... >>> page.get() 'Teszt' >>> page.text 'Teszt' >>> # Now I delete [[Teszt]] manually ... >>> page.get() 'Teszt' >>> page.text 'Teszt' >>> page.exists() True >>> page.get(force=True) Traceback (most recent call last): File "<stdin>", line 1, in <module> File "c:\Pywikibot\pywikibot\page\_page.py", line 397, in get self._getInternals() File "c:\Pywikibot\pywikibot\page\_page.py", line 436, in _getInternals self.site.loadrevisions(self, content=True) File "c:\Pywikibot\pywikibot\site\_generators.py", line 772, in loadrevisions raise NoPageError(page) pywikibot.exceptions.NoPageError: Page [[hu:Teszt]] doesn't exist. >>> page.exists() True >>>
What happens?:
After page.get(force=True) the page data were not refreshed sufficiently. page.exists() believes the page is still existing.
What should have happened instead?:
page.get(force=True) should refresh self.pageid so that page.exists() will not be mislead.
I don't know what further measures are neccessary for other methods.
Documentation of page.exists() should clearly describe what happens and how to force rechecking.
Steps to replicate the issue:
page = pywikibot.Page(site, 'Teszt') print('Exists:', page.exists()) print('Id:', page.pageid) page.text = 'Teszt' page.save('Botteszt') print('Exists:', page.exists()) print('Id:', page.pageid)
What happens?:
Exists: False Id: 0 Page [[Teszt]] saved Exists: False Id: 0
What should have happened instead?:
Page.revid should have been updated upon save().
Software version (skip for WMF-hosted wikis like Wikipedia): 8.0.0