Page MenuHomePhabricator

Page.authorship() sometimes raises a TypeError
Closed, ResolvedPublicBUG REPORT

Description

Script terminated by exception:

ERROR: 'NoneType' object is not subscriptable (TypeError)
Traceback (most recent call last):
  File "D:\pwb\core\pywikibot\page\_toolforge.py", line 192, in authorship
    table = wikitextparser.parse(r.text).tables[0]
            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^
IndexError: list index out of range

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "D:\pwb\core\pwb.py", line 40, in <module>
    sys.exit(main())
             ^^^^^^
  File "D:\pwb\core\pwb.py", line 36, in main
    runpy.run_path(str(path), run_name='__main__')
  File "<frozen runpy>", line 291, in run_path
  File "<frozen runpy>", line 98, in _run_module_code
  File "<frozen runpy>", line 88, in _run_code
  File "D:\pwb\core\pywikibot\scripts\wrapper.py", line 523, in <module>
    main()
  File "D:\pwb\core\pywikibot\scripts\wrapper.py", line 507, in main
    if not execute():
           ^^^^^^^^^
  File "D:\pwb\core\pywikibot\scripts\wrapper.py", line 494, in execute
    run_python_file(filename, script_args, module)
  File "D:\pwb\core\pywikibot\scripts\wrapper.py", line 149, in run_python_file
    exec(compile(source, filename, 'exec', dont_inherit=True),
  File "D:\pwb\xqbot\deletion_request_notifier.py", line 399, in <module>
    main()
  File "D:\pwb\xqbot\deletion_request_notifier.py", line 389, in main
    bot.run()
  File "D:\pwb\xqbot\deletion_request_notifier.py", line 141, in run
    super().run()
  File "D:\pwb\core\pywikibot\bot.py", line 1582, in run
    self.treat(page)
  File "D:\pwb\core\pywikibot\bot.py", line 1835, in treat
    self.treat_page()
  File "D:\pwb\xqbot\deletion_request_notifier.py", line 227, in treat_page
    for author, percent in self.find_authors(page, previd):
  File "D:\pwb\xqbot\deletion_request_notifier.py", line 284, in find_authors
    auth = page.authorship(
           ^^^^^^^^^^^^^^^^
  File "D:\pwb\core\pywikibot\page\_toolforge.py", line 195, in authorship
    msg = textlib.removeHTMLParts(pattern.search(r.text)[0])
                                  ~~~~~~~~~~~~~~~~~~~~~~^^^
TypeError: 'NoneType' object is not subscriptable
CRITICAL: Exiting due to uncaught exception TypeError: 'NoneType' object is not subscriptable

Event Timeline

Xqt changed the task status from Open to In Progress.Oct 9 2024, 3:32 PM
Xqt triaged this task as Medium priority.
Xqt changed the subtype of this task from "Task" to "Bug Report".

Change #1078976 had a related patch set uploaded (by Xqt; author: Xqt):

[pywikibot/core@master] [IMPR] Show strong messages in case of missing error code in Page.authorship()

https://gerrit.wikimedia.org/r/1078976

Change #1078976 merged by jenkins-bot:

[pywikibot/core@master] [IMPR] Show strong messages in case of missing error code in Page.authorship()

https://gerrit.wikimedia.org/r/1078976