From db02997add56e7d92b9989c68380775fcad5a456 Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+aa-turner@users.noreply.github.com> Date: Fri, 22 Nov 2024 14:14:23 +0000 Subject: [PATCH] Ensure `changeset.descname` is a string when not None --- sphinx/builders/changes.py | 5 +---- sphinx/directives/__init__.py | 6 +++++- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/sphinx/builders/changes.py b/sphinx/builders/changes.py index 918ed3bcaee..49cab2c7a8c 100644 --- a/sphinx/builders/changes.py +++ b/sphinx/builders/changes.py @@ -61,10 +61,7 @@ def write_documents(self, _docnames: Set[str]) -> None: return logger.info(bold(__('writing summary file...'))) for changeset in changesets: - if isinstance(changeset.descname, tuple): - descname = changeset.descname[0] - else: - descname = changeset.descname + descname = changeset.descname ttext = self.typemap[changeset.type] context = changeset.content.replace('\n', ' ') if descname and changeset.docname.startswith('c-api'): diff --git a/sphinx/directives/__init__.py b/sphinx/directives/__init__.py index 181c6f81a07..c45232c92e7 100644 --- a/sphinx/directives/__init__.py +++ b/sphinx/directives/__init__.py @@ -282,7 +282,11 @@ def run(self) -> list[Node]: if self.names: # needed for association of version{added,changed} directives - self.env.temp_data['object'] = self.names[0] + object_name: ObjDescT = self.names[0] + if isinstance(object_name, tuple): + self.env.temp_data['object'] = str(object_name[0]) + else: + self.env.temp_data['object'] = str(object_name) self.before_content() content_children = self.parse_content_to_nodes(allow_section_headings=True) content_node = addnodes.desc_content('', *content_children)