Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 1ffa3fc

Browse files
committedDec 26, 2023
Fix parsing of tags
1 parent aa794ad commit 1ffa3fc

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed
 

‎src/sage/doctest/parsing.py

+7-3
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,10 @@ def parse_optional_tags(
241241

242242
tags: dict[str, Union[str, None]] = {}
243243
for m in optional_regex.finditer(comment):
244-
cmd = m.group("cmd").lower()
244+
cmd = m.group("cmd").lower().strip()
245+
if cmd == "":
246+
# skip empty tags
247+
continue
245248
if cmd == "known bug":
246249
value = None
247250
if m.groups("tags") and m.group("tags").strip().lower().startswith("linux"):
@@ -252,13 +255,14 @@ def parse_optional_tags(
252255
# rename 'known bug' to 'bug' so that such tests will be run by sage -t ... -only-optional=bug
253256
tags["bug"] = value
254257
elif cmd not in ["optional", "needs"]:
255-
tags[cmd.lower()] = m.group("cmd_explanation") or None
258+
tags[cmd] = m.group("cmd_explanation") or None
256259
else:
257260
# other tags with additional values
258261
tags_with_value = {
259-
m.group(1).lower(): m.group(2) or None
262+
m.group(1).lower().strip(): m.group(2) or None
260263
for m in tag_with_explanation_regex.finditer(m.group("tags"))
261264
}
265+
tags_with_value.pop("", None)
262266
tags.update(tags_with_value)
263267

264268
if return_string_sans_tags:

0 commit comments

Comments
 (0)
Please sign in to comment.