Skip to content

Commit 7a093da

Browse files
woodruffwAA-Turner
andauthored
Infra: Make PEP abstract extration more robust (#4356)
This eliminates an AttributeError during PEP editing, if the PEP being edited has an Abstract or Introduction section but with no interior content (i.e. paragraphs) yet. In practice this should have no effect on actual RSS feeds, since merged PEPs should always have a proper abstract. However, this prevents a confusing error from bubbling up during local editing. See #4355. Signed-off-by: William Woodruff <william@yossarian.net> Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
1 parent 0f41cdf commit 7a093da

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

pep_sphinx_extensions/generate_rss.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,10 @@ def pep_abstract(document: nodes.document) -> str:
6060
continue
6161

6262
if title_node.astext() == "Abstract":
63-
return node.next_node(nodes.paragraph).astext().strip().replace("\n", " ")
64-
elif title_node.astext() == "Introduction":
63+
if (para_node := node.next_node(nodes.paragraph)) is not None:
64+
return para_node.astext().strip().replace("\n", " ")
65+
return ""
66+
if title_node.astext() == "Introduction":
6567
introduction = node.next_node(nodes.paragraph).astext().strip().replace("\n", " ")
6668

6769
return introduction

0 commit comments

Comments
 (0)