Huji has uploaded a new change for review. ( 
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, 11 insertions(+), 5 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/pywikibot/core 
refs/changes/56/329656/1

diff --git a/pywikibot/textlib.py b/pywikibot/textlib.py
index 9f7782e..3e4b765 100644
--- a/pywikibot/textlib.py
+++ b/pywikibot/textlib.py
@@ -1101,11 +1101,17 @@
             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)
+            result.append(cat)
+        except:
+            # Category title extracted contains invalid characters
+            # Likely due to on-the-fly category name creation, see T154309
+            pywikibot.warning('Invalid category title extracted: %' % title)
+
     return result
 
 

-- 
To view, visit https://gerrit.wikimedia.org/r/329656
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Id12ca20f7acbaac78bd3afe76970d3cd7631e1b1
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Huji <huji.h...@gmail.com>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to