Page MenuHomePhabricator

Pywikibot does not handle InvalidTitle error
Closed, InvalidPublic

Description

Using touch.py, I sent the following request with a typo in it, which included illegal characters. This causes the script to terminate, rather than continue to next page (if there had been one). Also, while handling the error, Pywikibot printed the full Python traceback to the terminal along with the PWB error message.

$ pwb.py touch -page:"San Patricio County News (Sinton, Tex.), Vol. 14, No. 39, Ed. 1 Thursday, November 2, 1922 - DPLA - e0a56764e41dd7bf3e7dcdfe32866585 (page 4).jpg
San Patricio County News (Sinton, Tex.), Vol. 14, No. 39, Ed. 1 Thursday, November 2, 1922 - DPLA - e0a56764e41dd7bf3e7dcdfe32866585 (page 4).jpg"

0 pages read
0 pages written
0 pages skipped
Execution time: 0 seconds
Script terminated by exception:

ERROR: InvalidTitle: 'San Patricio County News (Sinton, Tex.), Vol. 14, No. 39, Ed. 1 Thursday, November 2, 1922 - DPLA - e0a56764e41dd7bf3e7dcdfe32866585 (page 4).jpg\nSan Patricio County News (Sinton, Tex.), Vol. 14, No. 39, Ed. 1 Thursday, November 2, 1922 - DPLA - e0a56764e41dd7bf3e7dcdfe32866585 (page 4).jpg' contains illegal char(s) '\n'
Traceback (most recent call last):
  File "/srv/paws/pwb/pwb.py", line 363, in <module>
    if not main():
  File "/srv/paws/pwb/pwb.py", line 358, in main
    file_package)
  File "/srv/paws/pwb/pwb.py", line 75, in run_python_file
    main_mod.__dict__)
  File "/srv/paws/pwb/scripts/touch.py", line 117, in <module>
    main()
  File "/srv/paws/pwb/scripts/touch.py", line 111, in main
    bot_class(generator=gen, **options).run()
  File "/srv/paws/pwb/pywikibot/bot.py", line 1686, in run
    super().run()
  File "/srv/paws/pwb/pywikibot/bot.py", line 1470, in run
    for item in self.generator:
  File "/srv/paws/pwb/pywikibot/pagegenerators.py", line 2086, in PreloadingGenerator
    site = page.site
  File "/srv/paws/pwb/pywikibot/page/__init__.py", line 231, in site
    return self._link.site
  File "/srv/paws/pwb/pywikibot/page/__init__.py", line 5924, in site
    self.parse()
  File "/srv/paws/pwb/pywikibot/page/__init__.py", line 5879, in parse
    '%r contains illegal char(s) %r' % (t, m.group(0)))
pywikibot.exceptions.InvalidTitle: 'San Patricio County News (Sinton, Tex.), Vol. 14, No. 39, Ed. 1 Thursday, November 2, 1922 - DPLA - e0a56764e41dd7bf3e7dcdfe32866585 (page 4).jpg\nSan Patricio County News (Sinton, Tex.), Vol. 14, No. 39, Ed. 1 Thursday, November 2, 1922 - DPLA - e0a56764e41dd7bf3e7dcdfe32866585 (page 4).jpg' contains illegal char(s) '\n'
CRITICAL: Exiting due to uncaught exception <class 'pywikibot.exceptions.InvalidTitle'>

Event Timeline

Dominicbm renamed this task from Pywikibot does not suppress InvalidTitle error traceback to Pywikibot does not handle InvalidTitle error.Dec 29 2020, 5:31 PM
Dominicbm updated the task description. (Show Details)
Xqt added a subscriber: Xqt.

I thinkt this behaviour is valid as long as the invalid title is not generated from any API request.