https://bugzilla.wikimedia.org/show_bug.cgi?id=55272
--- Comment #6 from Kunal Mehta (Legoktm) legoktm.wikipedia@gmail.com --- The bug fix in r8329 doesn't correct the problem. This is perhaps because I mis-analyzed the problem. In fact the try ... except block in siteinfo accomplishes nothing, since the KeyError occurs outside its scope. So, what really happens is the exception occurs and propagates. However, the value returned on an exception is None. So, it propagates through getmagicwords to redirectRegex. For some reason I don't understand, it is not caught by the except clause there before the pattern statement executes (causing the type error).
The solution (which I have tested) is to put a try ... except block in getmagicwords and return None when a KeyError occurs. This consumes the KeyError exception and allows the change in r8333 to redirectRegex to work properly. In addition, it makes no sense to have the try ... except block in siteinfo, since it isn't possible for a KeyError to occur as the result of either of the two return statements.
I will attach a patch against r8333 that fixes the problem.