From 98f6e2410678a3e5cb8ec11a3cdcc5365008f3e4 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Mon, 6 Jun 2022 08:17:15 +0530 Subject: [PATCH] Move block outside try/except as it doesnt need to be in there --- kittens/hints/main.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/kittens/hints/main.py b/kittens/hints/main.py index 79f193e78..01fa9384b 100644 --- a/kittens/hints/main.py +++ b/kittens/hints/main.py @@ -330,15 +330,14 @@ def mark(pattern: str, post_processors: Iterable[PostprocessorFunc], text: str, try: for func in post_processors: s, e = func(text, s, e) - groupdict = match_object.groupdict() - for group_name in groupdict: - group_idx = pat.groupindex[group_name] - gs, ge = match_object.span(group_idx) - gs, ge = max(gs, s), min(ge, e) - groupdict[group_name] = sanitize_pat.sub('', text[gs:ge]) except InvalidMatch: continue - + groupdict = match_object.groupdict() + for group_name in groupdict: + group_idx = pat.groupindex[group_name] + gs, ge = match_object.span(group_idx) + gs, ge = max(gs, s), min(ge, e) + groupdict[group_name] = sanitize_pat.sub('', text[gs:ge]) mark_text = sanitize_pat.sub('', text[s:e]) yield Mark(idx, s, e, mark_text, groupdict)