mirror of
https://github.com/python/cpython.git
synced 2025-08-31 05:58:33 +00:00
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().
This commit is contained in:
parent
f7039e29ec
commit
9a80e00cac
1 changed files with 1 additions and 0 deletions
|
@ -167,6 +167,7 @@ class RegexObject:
|
||||||
regs = match(source, pos, end, 0)
|
regs = match(source, pos, end, 0)
|
||||||
if not regs:
|
if not regs:
|
||||||
break
|
break
|
||||||
|
self._num_regs = len(regs)
|
||||||
i, j = regs[0]
|
i, j = regs[0]
|
||||||
if i == j == lastmatch:
|
if i == j == lastmatch:
|
||||||
# Empty match adjacent to previous match
|
# Empty match adjacent to previous match
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue