# Buggy code
def repr_domxml(node, length=80):
    # type: (nodes.Node, Optional[int]) -> unicode
    """
    return DOM XML representation of the specified node like:
    '<paragraph translatable="False"><inline classes="versionmodified">New in version...'

    :param nodes.Node node: target node
    :param int length:
       length of return value to be striped. if false-value is specified, repr_domxml
       returns full of DOM XML representation.
    :return: DOM XML representation
    """
    text = node.asdom().toxml()
    if length and len(text) > length:
        text = text[:length] + "..."
    return text


# Traceback (TypeError)
# Sphinx version: 1.8.0+
# Python version: 3.6.6 (CPython)
# Docutils version: 0.14
# Jinja2 version: 2.10
# Last messages:
#   building [mo]: targets for 0 po files that are out of date
#
#   building [html]: targets for 1 source files that are out of date
#
#   updating environment:
#
#   1 added, 0 changed, 0 removed
#
#   reading sources... [100%] index
#
# Loaded extensions:
#   alabaster (0.7.11) from /opt/miniconda3/lib/python3.6/site-packages/alabaster/__init__.py
#   pyspecific (1.0) from /PATH/TO/PROJECTDIR/pyspecific.py
Traceback (most recent call last):
File "/PATH/TO/sphinx/sphinx/cmd/build.py", line 302, in build_main
app.build(args.force_all, filenames)
File "/PATH/TO/sphinx/sphinx/application.py", line 335, in build
self.builder.build_update()
File "/PATH/TO/sphinx/sphinx/builders/__init__.py", line 350, in build_update
len(to_build))
File "/PATH/TO/sphinx/sphinx/builders/__init__.py", line 363, in build
updated_docnames = set(self.read())
File "/PATH/TO/sphinx/sphinx/builders/__init__.py", line 471, in read
self._read_serial(docnames)
File "/PATH/TO/sphinx/sphinx/builders/__init__.py", line 493, in _read_serial
self.read_doc(docname)
File "/PATH/TO/sphinx/sphinx/builders/__init__.py", line 537, in read_doc
doctree = read_doc(self.app, self.env, self.env.doc2path(docname))
File "/PATH/TO/sphinx/sphinx/io.py", line 324, in read_doc
pub.publish()
File "/opt/miniconda3/lib/python3.6/site-packages/docutils/core.py", line 218, in publish
self.apply_transforms()
File "/opt/miniconda3/lib/python3.6/site-packages/docutils/core.py", line 199, in apply_transforms
self.document.transformer.apply_transforms()
File "/PATH/TO/sphinx/sphinx/transforms/__init__.py", line 90, in apply_transforms
Transformer.apply_transforms(self)
File "/opt/miniconda3/lib/python3.6/site-packages/docutils/transforms/__init__.py", line 171, in apply_transforms
transform.apply(**kwargs)
File "/PATH/TO/sphinx/sphinx/transforms/i18n.py", line 105, in apply
for node, msg in extract_messages(self.document):
File "/PATH/TO/sphinx/sphinx/util/nodes.py", line 197, in extract_messages
for node in doctree.traverse(is_translatable):
File "/opt/miniconda3/lib/python3.6/site-packages/docutils/nodes.py", line 266, in traverse
condition=condition))
File "/opt/miniconda3/lib/python3.6/site-packages/docutils/nodes.py", line 266, in traverse
condition=condition))
File "/opt/miniconda3/lib/python3.6/site-packages/docutils/nodes.py", line 260, in traverse
if include_self and (condition is None or condition(self)):
File "/PATH/TO/sphinx/sphinx/util/nodes.py", line 155, in is_translatable
get_full_module_name(node), repr_domxml(node))
File "/PATH/TO/sphinx/sphinx/util/nodes.py", line 59, in repr_domxml
text = node.asdom().toxml()
File "/opt/miniconda3/lib/python3.6/site-packages/docutils/nodes.py", line 74, in asdom
return self._dom_node(domroot)
File "/opt/miniconda3/lib/python3.6/site-packages/docutils/nodes.py", line 492, in _dom_node
element.setAttribute(attribute, '%s' % value)
TypeError: not all arguments converted during string formatting

# Fixed code
def repr_domxml(node, length=80):
    # type: (nodes.Node, Optional[int]) -> unicode
    """
    return DOM XML representation of the specified node like:
    '<paragraph translatable="False"><inline classes="versionmodified">New in version...'

    :param nodes.Node node: target node
    :param int length:
       length of return value to be striped. if false-value is specified, repr_domxml
       returns full of DOM XML representation.
    :return: DOM XML representation
    """
    try:
        text = node.asdom().toxml()
    except Exception:
        text = text_type(node)
    if length and len(text) > length:
        text = text[:length] + "..."
    return text