jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/892044 )
Change subject: [FIX] Avoid error when replacement includes backslash ......................................................................
[FIX] Avoid error when replacement includes backslash
Bug: T330021 Change-Id: I2255449aca7d496df4c56882997e254cb410d88e --- M pywikibot/textlib.py 1 file changed, 12 insertions(+), 1 deletion(-)
Approvals: Meno25: Looks good to me, but someone else must approve Xqt: Looks good to me, approved jenkins-bot: Verified
diff --git a/pywikibot/textlib.py b/pywikibot/textlib.py index 3079c22..1e09f87 100644 --- a/pywikibot/textlib.py +++ b/pywikibot/textlib.py @@ -1214,7 +1214,8 @@ if re.match(fr'\s*{marker}', lastpart): # Put the langlinks back into the noinclude's regexp = re.compile(fr'{includeOff}\s*{marker}') - newtext = regexp.sub(s + includeOff, s2) + # replace via lambda due to T330021 + newtext = regexp.sub(lambda m: s + includeOff, s2) else: # Put the langlinks at the end, inside noinclude's newtext = (s2.replace(marker, '').strip()