jenkins-bot has submitted this change and it was merged.
Change subject: Allow empty match replace ......................................................................
Allow empty match replace
The patch fix a problem with empty matched group that encountered in replacebot used in hewiki. Sometimes we want to match empty groups
eg /RISHMI(T |IM)?/ would give None for 'RISHMI '
Change-Id: I58dd59a884b1be3c67627a5f4af7acc036c98699 --- M pywikibot/textlib.py 1 file changed, 1 insertion(+), 1 deletion(-)
Approvals: Merlijn van Deen: Looks good to me, approved jenkins-bot: Verified
diff --git a/pywikibot/textlib.py b/pywikibot/textlib.py index ffa7520..ef1207f 100644 --- a/pywikibot/textlib.py +++ b/pywikibot/textlib.py @@ -232,7 +232,7 @@ int(groupMatch.group('number'))) try: replacement = (replacement[:groupMatch.start()] + - match.group(groupID) + \ + ('' if match.group(groupID) is None else match.group(groupID)) + \ replacement[groupMatch.end():]) except IndexError: pywikibot.output('\nInvalid group reference: %s' % groupID)
pywikibot-commits@lists.wikimedia.org