I asked bryan to make this commit because it's actually crashing for languages that don't have localized templates :
Translate() defaults to 'en', and 'en' dictionary values are None, so it'll crash, trying to iterate on a None object. This fix is temporary, and can be reverted, once 'en' template names are properly configured.
Revision: 5137
Author: btongminh
Date: 2008-03-16 20:02:16 +0000 (Sun, 16 Mar 2008)
Log Message:
-----------
Don't iterate on TTP or TSP if they are None. (patch by NicDumZ)
Modified Paths:
--------------
trunk/pywikipedia/blockpageschecker.py
Modified: trunk/pywikipedia/blockpageschecker.py
===================================================================
--- trunk/pywikipedia/blockpageschecker.py 2008-03-16 12:30:29 UTC (rev 5136)
+++ trunk/pywikipedia/blockpageschecker.py 2008-03-16 20:02:16 UTC (rev 5137)
@@ -161,14 +161,16 @@
def understandBlock(text, TTP, TSP, TSMP, TTMP):
""" Understand if the page is blocked and if it has the right template """
- for catchRegex in TTP: # TTP = templateTotalProtection
- resultCatch = re.findall(catchRegex, text)
- if resultCatch != []:
- return ('sysop-total', catchRegex)
- for catchRegex in TSP:
- resultCatch = re.findall(catchRegex, text)
- if resultCatch != []:
- return ('autoconfirmed-total', catchRegex)
+ if TTP:
+ for catchRegex in TTP: # TTP = templateTotalProtection
+ resultCatch = re.findall(catchRegex, text)
+ if resultCatch != []:
+ return ('sysop-total', catchRegex)
+ if TSP:
+ for catchRegex in TSP:
+ resultCatch = re.findall(catchRegex, text)
+ if resultCatch != []:
+ return ('autoconfirmed-total', catchRegex)
if TSMP != None and TTMP != None and TTP != TTMP and TSP != TSMP:
for catchRegex in TSMP:
resultCatch = re.findall(catchRegex, text)
_______________________________________________
Pywikipedia-l mailing list
Pywikipedia-l@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/pywikipedia-l