Page MenuHomePhabricator

commonscat.py: pywikibot.exceptions.InvalidTitleError: 'Category:' has no title
Closed, ResolvedPublic

Description

Command line:

python pwb.py commonscat -site:wikiquote:ar -page:"الاستبداد"

Output:

Script terminated by exception:

ERROR: InvalidTitleError: 'Category:' has no title.
Traceback (most recent call last):
  File "C:\Users\Mohammed\Downloads\core\pwb.py", line 365, in <module>
    if not main():
  File "C:\Users\Mohammed\Downloads\core\pwb.py", line 357, in main
    run_python_file(filename,
  File "C:\Users\Mohammed\Downloads\core\pwb.py", line 73, in run_python_file
    exec(compile(source, filename, 'exec', dont_inherit=True),
  File ".\scripts\commonscat.py", line 552, in <module>
    main()
  File ".\scripts\commonscat.py", line 546, in main
    bot.run()
  File "C:\Users\Mohammed\Downloads\core\pywikibot\bot.py", line 1533, in run
    self.treat(page)
  File "C:\Users\Mohammed\Downloads\core\pywikibot\bot.py", line 1814, in treat
    self.treat_page()
  File ".\scripts\commonscat.py", line 318, in treat_page
    commonscatLink = self.find_commons_category(page)
  File ".\scripts\commonscat.py", line 412, in find_commons_category
    return self.findCommonscatLink(page)
  File ".\scripts\commonscat.py", line 385, in findCommonscatLink
    checkedCommonscat = self.checkCommonscatLink(commonscatLink[1])
  File ".\scripts\commonscat.py", line 454, in checkCommonscatLink
    if not commonsPage.exists():
  File "C:\Users\Mohammed\Downloads\core\pywikibot\page\__init__.py", line 710, in exists
    return self.pageid > 0
  File "C:\Users\Mohammed\Downloads\core\pywikibot\page\__init__.py", line 258, in pageid
    self.site.loadpageinfo(self)
  File "C:\Users\Mohammed\Downloads\core\pywikibot\page\__init__.py", line 195, in site
    return self._link.site
  File "C:\Users\Mohammed\Downloads\core\pywikibot\page\__init__.py", line 5382, in site
    self.parse()
  File "C:\Users\Mohammed\Downloads\core\pywikibot\page\__init__.py", line 5278, in parse
    raise InvalidTitleError(
pywikibot.exceptions.InvalidTitleError: 'Category:' has no title.
CRITICAL: Exiting due to uncaught exception <class 'pywikibot.exceptions.InvalidTitleError'>

Output of version.py:

Pywikibot: [https] r-pywikibot-core (f60f6f3, g14825, 2021/05/12, 07:52:57, master)
Release version: 6.2.0.dev0
requests version: 2.25.1
    certificate test: ok
Python: 3.9.5 (tags/v3.9.5:0a7dcbd, May  3 2021, 17:27:52) [MSC v.1928 64 bit (AMD64)]

Request:

Please make the bot skip the page (and not crash) when encountering such exceptions to save me the time to manually restart the bot every time it crashes. Thank you.

Event Timeline

Xqt triaged this task as Medium priority.

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

[pywikibot/core@master] [bugfix] exit checkCommonscatLink method if target name is empty

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

Change 690034 merged by jenkins-bot:

[pywikibot/core@master] [bugfix] exit checkCommonscatLink method if target name is empty

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