# Buggy code
def merge_domaindata(self, docnames, otherdata):
    # type: (List[unicode], Dict) -> None
    self.data["root_symbol"].merge_with(otherdata["root_symbol"], docnames, self.env)
    ourNames = self.data["names"]
    for name, docname in otherdata["names"].items():
        if docname in docnames:
            if name in ourNames:
                msg = "Duplicate declaration, also defined in '%s'.\n"
                msg += "Name of declaration is '%s'."
                msg = msg % (ourNames[name], name)
                logger.warning(msg, docname)
            else:
                ourNames[name] = docname


# Traceback (TypeError)
--- Logging error ---
Traceback (most recent call last):
File "/usr/lib/python3.6/logging/__init__.py", line 992, in emit
msg = self.format(record)
File "/usr/lib/python3.6/logging/__init__.py", line 838, in format
return fmt.format(record)
File "/usr/lib/python3.6/site-packages/sphinx/util/logging.py", line 445, in format
message = super(ColorizeFormatter, self).format(record)
File "/usr/lib/python3.6/logging/__init__.py", line 575, in format
record.message = record.getMessage()
File "/usr/lib/python3.6/site-packages/sphinx/util/logging.py", line 96, in getMessage
message = super(SphinxWarningLogRecord, self).getMessage()
File "/usr/lib/python3.6/logging/__init__.py", line 338, in getMessage
msg = msg % self.args
TypeError: not all arguments converted during string formatting
Call stack:
File "/usr/bin/sphinx-build", line 11, in <module>
load_entry_point('Sphinx==1.7.3', 'console_scripts', 'sphinx-build')()
File "/usr/lib/python3.6/site-packages/sphinx/cmd/build.py", line 38, in main
return build_main(argv)
File "/usr/lib/python3.6/site-packages/sphinx/cmd/build.py", line 23, in build_main
return cmdline.main(argv)  # type: ignore
File "/usr/lib/python3.6/site-packages/sphinx/cmdline.py", line 304, in main
app.build(args.force_all, filenames)
File "/usr/lib/python3.6/site-packages/sphinx/application.py", line 331, in build
self.builder.build_update()
File "/usr/lib/python3.6/site-packages/sphinx/builders/__init__.py", line 338, in build_update
'out of date' % len(to_build))
File "/usr/lib/python3.6/site-packages/sphinx/builders/__init__.py", line 351, in build
updated_docnames = set(self.env.update(self.config, self.srcdir, self.doctreedir))
File "/usr/lib/python3.6/contextlib.py", line 88, in __exit__
next(self.gen)
File "/usr/lib/python3.6/site-packages/sphinx/util/logging.py", line 240, in pending_warnings
memhandler.flushTo(logger)
File "/usr/lib/python3.6/site-packages/sphinx/util/logging.py", line 206, in flushTo
logger.handle(record)
Message: "Duplicate declaration, also defined in 'subsystems/sensor'.\nName of declaration is 'sensor_value'."
Arguments: ('api/io_interfaces',)

# Fixed code
def merge_domaindata(self, docnames, otherdata):
    # type: (List[unicode], Dict) -> None
    self.data["root_symbol"].merge_with(otherdata["root_symbol"], docnames, self.env)
    ourNames = self.data["names"]
    for name, docname in otherdata["names"].items():
        if docname in docnames:
            if name in ourNames:
                msg = "Duplicate declaration, also defined in '%s'.\n"
                msg += "Name of declaration is '%s'."
                msg = msg % (ourNames[name], name)
                logger.warning(msg, location=docname)
            else:
                ourNames[name] = docname