Skip to content

Commit

Permalink
Return the default value for unsupported theme configuration sections
Browse files Browse the repository at this point in the history
  • Loading branch information
AA-Turner committed Apr 19, 2024
1 parent 62c3bad commit 4a0c9dd
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
4 changes: 3 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ Bugs fixed
* #12299: Defer loading themes defined via entry points until
their explicit use by the user or a child theme.
Patch by Adam Turner.

* #12305: Return the default value for ``theme.get_config()`` with
an unsupported theme configuration section.
Patch by Adam Turner.

Release 7.3.6 (released Apr 17, 2024)
=====================================
Expand Down
12 changes: 11 additions & 1 deletion sphinx/theming.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,17 @@ def get_config(self, section: str, name: str, default: Any = _NO_DEFAULT) -> Any
elif section == 'options':
value = self._options.get(name, default)
else:
value = _NO_DEFAULT
# https://github.com/sphinx-doc/sphinx/issues/12305
# For backwards compatibility when attempting to read a value
# from an unsupported configuration section.
# xref: RemovedInSphinx80Warning
msg = __(
'Theme configuration sections other than [theme] and [options] '
'are not supported, returning the default value instead '
'(tried to get a value from %r)'
)
logger.info(msg % section)
value = default
if value is _NO_DEFAULT:
msg = __('setting %s.%s occurs in none of the searched theme configs') % (
section,
Expand Down

0 comments on commit 4a0c9dd

Please sign in to comment.