Page MenuHomePhabricator

commonscat.py: uncaught exception: InvalidTitle: '{{PAGENAME}}' contains illegal char(s) '{'
Open, MediumPublic

Description

Command line:

python3 pwb.py commonscat -lang:ary -start:!

Output:

Retrieving 1 pages from wikipedia:ary.


>>> أحلاف <<<

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

ERROR: InvalidTitle: '{{PAGENAME}}' contains illegal char(s) '{'
Traceback (most recent call last):
  File "pwb.py", line 363, in <module>
    if not main():
  File "pwb.py", line 358, in main
    file_package)
  File "pwb.py", line 75, in run_python_file
    main_mod.__dict__)
  File "./scripts/commonscat.py", line 561, in <module>
    main()
  File "./scripts/commonscat.py", line 555, in main
    bot.run()
  File "/mnt/nfs/labstore-secondary-tools-home/meno25/core/pywikibot/bot.py", line 1487, in run
    self.treat(page)
  File "/mnt/nfs/labstore-secondary-tools-home/meno25/core/pywikibot/bot.py", line 1766, in treat
    self.treat_page()
  File "./scripts/commonscat.py", line 316, in treat_page
    commonscatLink = self.find_commons_category(page)
  File "./scripts/commonscat.py", line 417, in find_commons_category
    return self.findCommonscatLink(page)
  File "./scripts/commonscat.py", line 385, in findCommonscatLink
    commonscatLink[1])
  File "./scripts/commonscat.py", line 464, in checkCommonscatLink
    if not commonsPage.exists():
  File "/mnt/nfs/labstore-secondary-tools-home/meno25/core/pywikibot/page/__init__.py", line 775, in exists
    return self.pageid > 0
  File "/mnt/nfs/labstore-secondary-tools-home/meno25/core/pywikibot/page/__init__.py", line 292, in pageid
    self.site.loadpageinfo(self)
  File "/mnt/nfs/labstore-secondary-tools-home/meno25/core/pywikibot/page/__init__.py", line 228, in site
    return self._link.site
  File "/mnt/nfs/labstore-secondary-tools-home/meno25/core/pywikibot/page/__init__.py", line 6010, in site
    self.parse()
  File "/mnt/nfs/labstore-secondary-tools-home/meno25/core/pywikibot/page/__init__.py", line 5965, in parse
    '%r contains illegal char(s) %r' % (t, m.group(0)))
pywikibot.exceptions.InvalidTitle: '{{PAGENAME}}' contains illegal char(s) '{'
CRITICAL: Exiting due to uncaught exception <class 'pywikibot.exceptions.InvalidTitle'>

Problem:

  • When running the script commonscat.py, the bot crashes when encountering the above error.
  • This is annoying as I have to manually restart the bot again.

Notes:

Request:

Please implement the same fix for commonscat.py (i.e. make the bot skip the page in this case instead of crashing). Thank you.

Version information:

Pywikibot: [https] r-pywikibot-core (fae6c25, g13693, 2020/11/11, 11:39:36, master)
Release version: 5.2.0.dev0
requests version: 2.21.0
  cacerts: /etc/ssl/certs/ca-certificates.crt
    certificate test: ok
Python: 3.5.3 (default, Jul  9 2020, 13:00:10)
[GCC 6.3.0 20170516]

Event Timeline

Meno25 created this task.Nov 11 2020, 4:07 PM
Restricted Application added subscribers: pywikibot-bugs-list, alaa, Aklapper. · View Herald TranscriptNov 11 2020, 4:07 PM
Meno25 updated the task description. (Show Details)Nov 11 2020, 4:09 PM
Meno25 updated the task description. (Show Details)Nov 11 2020, 4:41 PM
Xqt triaged this task as Medium priority.Nov 11 2020, 6:07 PM
Xqt added a subscriber: Xqt.

@Meno25: you are the perfect beta-tester 😉

@Meno25: you are the perfect beta-tester 😉

Thank you ❤😊😊