Skip to content

Commit 4a0c9dd

Browse files
committed
Return the default value for unsupported theme configuration sections
1 parent 62c3bad commit 4a0c9dd

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

CHANGES.rst

+3-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ Bugs fixed
77
* #12299: Defer loading themes defined via entry points until
88
their explicit use by the user or a child theme.
99
Patch by Adam Turner.
10-
10+
* #12305: Return the default value for ``theme.get_config()`` with
11+
an unsupported theme configuration section.
12+
Patch by Adam Turner.
1113

1214
Release 7.3.6 (released Apr 17, 2024)
1315
=====================================

sphinx/theming.py

+11-1
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,17 @@ def get_config(self, section: str, name: str, default: Any = _NO_DEFAULT) -> Any
121121
elif section == 'options':
122122
value = self._options.get(name, default)
123123
else:
124-
value = _NO_DEFAULT
124+
# https://github.com/sphinx-doc/sphinx/issues/12305
125+
# For backwards compatibility when attempting to read a value
126+
# from an unsupported configuration section.
127+
# xref: RemovedInSphinx80Warning
128+
msg = __(
129+
'Theme configuration sections other than [theme] and [options] '
130+
'are not supported, returning the default value instead '
131+
'(tried to get a value from %r)'
132+
)
133+
logger.info(msg % section)
134+
value = default
125135
if value is _NO_DEFAULT:
126136
msg = __('setting %s.%s occurs in none of the searched theme configs') % (
127137
section,

0 commit comments

Comments
 (0)