From 39d050b5e03d7e8234dab141181e0d0dad742803 Mon Sep 17 00:00:00 2001 From: Philipp A Date: Sun, 29 Oct 2023 01:23:55 +0200 Subject: [PATCH] =?UTF-8?q?Infra:=20Make=20check-peps=E2=80=99=20=5Fvalida?= =?UTF-8?q?te=5Fpost=5Fhistory=20crash=20less=20(#3511)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Pradyun Gedam --- check-peps.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/check-peps.py b/check-peps.py index ea45cd161..93d367379 100755 --- a/check-peps.py +++ b/check-peps.py @@ -414,12 +414,15 @@ def _validate_post_history(line_num: int, body: str) -> MessageIterator: for offset, line in enumerate(body.removesuffix(",").split("\n"), start=line_num): for post in line.removesuffix(",").strip().split(", "): - if not post.startswith("`") and not post.endswith(">`__"): + prefix, postfix = (post.startswith("`"), post.endswith(">`__")) + if not prefix and not postfix: yield from _date(offset, post, "Post-History") - else: + elif prefix and postfix: post_date, post_url = post[1:-4].split(" <") yield from _date(offset, post_date, "Post-History") yield from _thread(offset, post_url, "Post-History") + else: + yield offset, f"post line must be a date or both start with “`” and end with “>`__”" def _validate_resolution(line_num: int, line: str) -> MessageIterator: