diff --git a/CHANGES.rst b/CHANGES.rst index be8a8133161..bb9373c817b 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -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) ===================================== diff --git a/sphinx/theming.py b/sphinx/theming.py index e05de2580e1..097efa44be2 100644 --- a/sphinx/theming.py +++ b/sphinx/theming.py @@ -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,