Page MenuHomePhabricator

harvest_template.py crashes on comment
Closed, ResolvedPublic

Description

pwb.py harvest_template -template:foo "Bar" P18

when P18 should be type image
and in infobox is
| Bar = <!-- some comment -->

Bot crashes

ERROR: u'<!-- some comment -->' contains illegal char(s) u'<'
Traceback (most recent call last):
  File "I:\pwb\pywikibot\bot.py", line 1927, in run
    self.treat(page, item)
  File ".\scripts\harvest_template.py", line 193, in treat
    image = pywikibot.FilePage(imagelink)
  File "I:\pwb\pywikibot\tools\__init__.py", line 1327, in wrapper
    return obj(*__args, **__kw)
  File "I:\pwb\pywikibot\page.py", line 2182, in __init__
    if self.namespace() != 6:
  File "I:\pwb\pywikibot\page.py", line 176, in namespace
    return self._link.namespace
  File "I:\pwb\pywikibot\page.py", line 5003, in namespace
    self.parse()
  File "I:\pwb\pywikibot\page.py", line 4947, in parse
    u"%s contains illegal char(s) %s" % (repr(t), repr(m.group(0))))
InvalidTitle: u'<!-- some comment -->' contains illegal char(s) u'<'

Additionally, when there is

| Bar = <!-- some [[comment]] -->, bot incorrectly adds [[comment]] intead of skipping

Event Timeline

Change 318273 had a related patch set uploaded (by Matěj Suchánek):
Remove comments etc. when parsing template

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

matej_suchanek renamed this task from harvest_template crashes on comment to harvest_template.py crashes on comment.Oct 27 2016, 10:43 AM
matej_suchanek claimed this task.

Change 318273 merged by jenkins-bot:
[pywikibot/core@master] Remove comments etc. when parsing template

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