Commits

Takayuki Shimizukawa committed 82a166b

fix debug2 UnicodeEncodeError issue with multibyte names node

Comments (0)

Files changed (2)

sphinx/application.py

             event.pop(listener_id, None)
 
     def emit(self, event, *args):
-        self.debug2('[app] emitting event: %r%s', event, str(args)[:100])
+        args_repr = repr(map(unicode, args))[:100]
+        self.debug2('[app] emitting event: %s%s', event, args_repr)
         results = []
         if event in self._listeners:
             for _, callback in self._listeners[event].iteritems():

tests/test_application.py

 
 from StringIO import StringIO
 
+from docutils import nodes
 from sphinx.application import ExtensionError
 from sphinx.domains import Domain
 
         "Callback called when disconnected"
 
 
+@with_app()
+def test_emit_with_multibyte_name_node(app):
+    node = nodes.section(names=[u'\u65e5\u672c\u8a9e'])
+    app.emit('my_event', node)
+
+
 def test_output():
     status, warnings = StringIO(), StringIO()
     app = TestApp(status=status, warning=warnings)