Page MenuHomePhabricator

delete an ItemPage results in TypeError
Closed, ResolvedPublic


I am trying to delete an instance of pywikibot.ItemPage using the delete function. After a recent pywikibot update to the latest version (r-pywikibot-core.git (7961cc8, g14506, 2021/03/26, 18:47:46, master)), my previously perfectly running script crashes and the trackback reads:

Traceback (most recent call last):
  File "../pywikibot/", line 363, in <module>
    if not main():
  File "../pywikibot/", line 358, in main
  File "../pywikibot/", line 75, in run_python_file
  File "", line 57, in <module>
    Qitem.delete(reason=editsummary, prompt=True, mark=False, quit=True)
  File "/mnt/nfs/labstore-secondary-tools-home/msyn/pywikibot/pywikibot/page/", line 1739, in delete, reason)
  File "/mnt/nfs/labstore-secondary-tools-home/msyn/pywikibot/pywikibot/site/", line 93, in callee
    return fn(self, *args, **kwargs)
  File "/mnt/nfs/labstore-secondary-tools-home/msyn/pywikibot/pywikibot/tools/", line 1445, in wrapper
    return obj(*__args, **__kw)
  File "/mnt/nfs/labstore-secondary-tools-home/msyn/pywikibot/pywikibot/site/", line 2073, in deletepage
    pageid = int(page)
TypeError: int() argument must be a string, a bytes-like object or a number, not 'ItemPage'
CRITICAL: Exiting due to uncaught exception <class 'TypeError'>

I think the problem is that in pywikibot/site/$2069, it checks isinstance(page, pywikibot.Page), which probably evaluates to False as pywikibot.ItemPage does *not* extend pywikibot.Page (it extends pywikibot.BasePage, however).

Event Timeline

Change 675345 had a related patch set uploaded (by JJMC89; author: JJMC89):
[pywikibot/core@master] [FIX] Allow deleting any subclass of BasePage by title

Xqt triaged this task as High priority.Mar 29 2021, 4:25 AM
Xqt added a subscriber: Mpaa.

Change 675345 merged by jenkins-bot:
[pywikibot/core@master] [FIX] Allow deleting any subclass of BasePage by title