jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/329656 )
Change subject: getCategoryLinks should catch invalid category title exceptions ......................................................................
getCategoryLinks should catch invalid category title exceptions
Bug: T154309 Change-Id: Id12ca20f7acbaac78bd3afe76970d3cd7631e1b1 --- M pywikibot/textlib.py 1 file changed, 12 insertions(+), 5 deletions(-)
Approvals: jenkins-bot: Verified Xqt: Looks good to me, approved
diff --git a/pywikibot/textlib.py b/pywikibot/textlib.py index 57c338a..c8e2926 100644 --- a/pywikibot/textlib.py +++ b/pywikibot/textlib.py @@ -1103,11 +1103,18 @@ title, sortKey = rest.split('|', 1) else: title, sortKey = rest, None - cat = pywikibot.Category(pywikibot.Link( - '%s:%s' % (match.group('namespace'), title), - site), - sortKey=sortKey) - result.append(cat) + try: + cat = pywikibot.Category(pywikibot.Link( + '%s:%s' % (match.group('namespace'), title), + site), + sortKey=sortKey) + except InvalidTitle: + # Category title extracted contains invalid characters + # Likely due to on-the-fly category name creation, see T154309 + pywikibot.warning('Invalid category title extracted: %s' % title) + else: + result.append(cat) + return result
pywikibot-commits@lists.wikimedia.org