From: Andrew M. Kuchling Date: Fri, 21 Aug 1998 18:39:38 +0000 (+0000) Subject: The .subn() method wasn't setting _num_regs, which is used by the .groups() X-Git-Tag: v1.5.2a2~364 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9a80e00cac40dd64709919c29386d8ede39f91d6;p=python The .subn() method wasn't setting _num_regs, which is used by the .groups() method, so .groups() didn't work inside the replacement function called by re.sub. One-line fix: set self._num_regs inside subn(). --- diff --git a/Lib/re.py b/Lib/re.py index dce29ceac9..d190363df4 100644 --- a/Lib/re.py +++ b/Lib/re.py @@ -167,6 +167,7 @@ class RegexObject: regs = match(source, pos, end, 0) if not regs: break + self._num_regs = len(regs) i, j = regs[0] if i == j == lastmatch: # Empty match adjacent to previous match