# Buggy code
def filter(self, record: logging.LogRecord) -> bool:
    if getattr(record, "skip_warningsiserror", False):
        # disabled by DisableWarningIsErrorFilter
        return True
    elif self.app.warningiserror:
        location = getattr(record, "location", "")
        try:
            message = record.msg % record.args
        except (TypeError, ValueError):
            message = record.msg  # use record.msg itself

        if location:
            raise SphinxWarning(location + ":" + message)
        else:
            raise SphinxWarning(message)
    else:
        return True


# Traceback (TypeError)
# Sphinx version: 3.0.0
# Python version: 3.8.0 (CPython)
# Docutils version: 0.16 release
# Jinja2 version: 2.11.1
# Last messages:
#   reading sources... [ 98%] whatsnew/3.3
#   reading sources... [ 98%] whatsnew/3.4
#   reading sources... [ 98%] whatsnew/3.5
#   reading sources... [ 98%] whatsnew/3.6
#   reading sources... [ 99%] whatsnew/3.7
#   reading sources... [ 99%] whatsnew/3.8
#   reading sources... [ 99%] whatsnew/3.9
#   reading sources... [ 99%] whatsnew/changelog
#   reading sources... [100%] whatsnew/index
#
# Loaded extensions:
#   sphinx.ext.mathjax (3.0.0) from /root/cpython/Doc/venv/lib/python3.8/site-packages/sphinx/ext/mathjax.py
#   sphinxcontrib.applehelp (1.0.2) from /root/cpython/Doc/venv/lib/python3.8/site-packages/sphinxcontrib/applehelp/__init__.py
#   sphinxcontrib.devhelp (1.0.2) from /root/cpython/Doc/venv/lib/python3.8/site-packages/sphinxcontrib/devhelp/__init__.py
#   sphinxcontrib.htmlhelp (1.0.3) from /root/cpython/Doc/venv/lib/python3.8/site-packages/sphinxcontrib/htmlhelp/__init__.py
#   sphinxcontrib.serializinghtml (1.1.4) from /root/cpython/Doc/venv/lib/python3.8/site-packages/sphinxcontrib/serializinghtml/__init__.py
#   sphinxcontrib.qthelp (1.0.3) from /root/cpython/Doc/venv/lib/python3.8/site-packages/sphinxcontrib/qthelp/__init__.py
#   alabaster (0.7.12) from /root/cpython/Doc/venv/lib/python3.8/site-packages/alabaster/__init__.py
#   sphinx.ext.coverage (3.0.0) from /root/cpython/Doc/venv/lib/python3.8/site-packages/sphinx/ext/coverage.py
#   sphinx.ext.doctest (3.0.0) from /root/cpython/Doc/venv/lib/python3.8/site-packages/sphinx/ext/doctest.py
#   pyspecific (1.0) from /root/cpython/Doc/tools/extensions/pyspecific.py
#   c_annotations (1.0) from /root/cpython/Doc/tools/extensions/c_annotations.py
#   escape4chm (1.0) from /root/cpython/Doc/tools/extensions/escape4chm.py
#   python_docs_theme (unknown version) from /root/cpython/Doc/venv/lib/python3.8/site-packages/python_docs_theme/__init__.py
Traceback (most recent call last):
File "/root/cpython/Doc/venv/lib/python3.8/site-packages/sphinx/cmd/build.py", line 280, in build_main
app.build(args.force_all, filenames)
File "/root/cpython/Doc/venv/lib/python3.8/site-packages/sphinx/application.py", line 348, in build
self.builder.build_update()
File "/root/cpython/Doc/venv/lib/python3.8/site-packages/sphinx/builders/__init__.py", line 297, in build_update
self.build(to_build,
File "/root/cpython/Doc/venv/lib/python3.8/site-packages/sphinx/builders/__init__.py", line 311, in build
updated_docnames = set(self.read())
File "/usr/lib/python3.8/contextlib.py", line 120, in __exit__
next(self.gen)
File "/root/cpython/Doc/venv/lib/python3.8/site-packages/sphinx/util/logging.py", line 213, in pending_warnings
memhandler.flushTo(logger)
File "/root/cpython/Doc/venv/lib/python3.8/site-packages/sphinx/util/logging.py", line 178, in flushTo
logger.handle(record)
File "/usr/lib/python3.8/logging/__init__.py", line 1587, in handle
self.callHandlers(record)
File "/usr/lib/python3.8/logging/__init__.py", line 1649, in callHandlers
hdlr.handle(record)
File "/usr/lib/python3.8/logging/__init__.py", line 946, in handle
rv = self.filter(record)
File "/usr/lib/python3.8/logging/__init__.py", line 807, in filter
result = f.filter(record)
File "/root/cpython/Doc/venv/lib/python3.8/site-packages/sphinx/util/logging.py", line 415, in filter
raise SphinxWarning(location + ":" + message)
TypeError: can only concatenate str (not "DefinitionError") to str

# Fixed code
def filter(self, record: logging.LogRecord) -> bool:
    if getattr(record, "skip_warningsiserror", False):
        # disabled by DisableWarningIsErrorFilter
        return True
    elif self.app.warningiserror:
        location = getattr(record, "location", "")
        try:
            message = record.msg % record.args
        except (TypeError, ValueError):
            message = record.msg  # use record.msg itself

        if location:
            raise SphinxWarning(location + ":" + str(message))
        else:
            raise SphinxWarning(message)
    else:
        return True