https://bugzilla.wikimedia.org/show_bug.cgi?id=54562
--- Comment #5 from Kunal Mehta (Legoktm) legoktm.wikipedia@gmail.com --- Yea, this is bugfix for 3539444 . In short: when running the following regex "ADMA (a)?poria" => "ADMA \1porya" on text containing ADMA poria (with no a before poria) it crashs with the following error doReplacements res = replace.ReplaceRobot.doReplacements(self,original_text) File "D:\myBot\python\pywikipedia-nightly\replace.py", line 390, in doReplacements allowoverlap=self.allowoverlap) File "D:\myBot\python\pywikipedia-nightly\pywikibot\textlib.py", line 179, in replaceExcept match.group(groupID) + \ TypeError: coercing to Unicode: need string or buffer, NoneType found
You may suggest to rewrite the specific regex and it may probably work, but it is just workaround - regex with optional capturing group is correct and should work properly. Longer story :) : In Hebrew Wikipedia there is a list of regexs that are used for replacements in all articles (almost). which is here: http://he.wikipedia.org/wiki/%D7%95%D7%A7:%D7%A8%D7%94 The columns in the table there are: ID | old | new | exceptText The list is used by C# bot implementation which isn't active, and by JS userscript implementation which is used for specific page replacements. I have ported it to work with replace.py, but if fails when it gets to replacement with optional capturing group. After my fix (locally) I ran it for 250 test edits and it worked properly without crashes