diff --git a/CHANGES b/CHANGES index 49782fb4686..1b06ad12506 100644 --- a/CHANGES +++ b/CHANGES @@ -4,6 +4,9 @@ Release 7.2.2 (in development) Bugs fixed ---------- +* Fixed membership testing (``in``) for the :py:class:`str` interface + of the asset classes (``_CascadingStyleSheet`` and ``_JavaScript``), + which several extensions relied upon. Release 7.2.1 (released Aug 17, 2023) ===================================== diff --git a/sphinx/builders/html/_assets.py b/sphinx/builders/html/_assets.py index 2d9247007a1..a72c5000bbc 100644 --- a/sphinx/builders/html/_assets.py +++ b/sphinx/builders/html/_assets.py @@ -36,6 +36,10 @@ def __str__(self): f'{attr})') def __eq__(self, other): + if isinstance(other, str): + warnings.warn('The str interface for _CascadingStyleSheet objects is deprecated. ' + 'Use css.filename instead.', RemovedInSphinx90Warning, stacklevel=2) + return self.filename == other if not isinstance(other, _CascadingStyleSheet): return NotImplemented return (self.filename == other.filename @@ -88,6 +92,10 @@ def __str__(self): f'{attr})') def __eq__(self, other): + if isinstance(other, str): + warnings.warn('The str interface for _JavaScript objects is deprecated. ' + 'Use js.filename instead.', RemovedInSphinx90Warning, stacklevel=2) + return self.filename == other if not isinstance(other, _JavaScript): return NotImplemented return (self.filename == other.filename