bpo-34294: re module, fix wrong capturing groups in rare cases. (GH-11546)


Need to reset capturing groups between two SRE(match) callings in loops, this fixes wrong capturing groups in rare cases.

Also add a missing index in re.rst.
(cherry picked from commit 4a7f44a2ed49ff1e87db062e7177a56c6e4bbdb0)

Co-authored-by: animalize <animalize@users.noreply.github.com>
diff --git a/Modules/_sre.c b/Modules/_sre.c
index d2ea62d..a97ce77 100644
--- a/Modules/_sre.c
+++ b/Modules/_sre.c
@@ -347,7 +347,7 @@
 LOCAL(void)
 state_reset(SRE_STATE* state)
 {
-    /* FIXME: dynamic! */
+    /* state->mark will be set to 0 in SRE_OP_MARK dynamically. */
     /*memset(state->mark, 0, sizeof(*state->mark) * SRE_MARK_SIZE);*/
 
     state->lastmark = -1;