diff options
| author | shimizukawa <shimizukawa@gmail.com> | 2013-01-21 03:44:31 +0000 |
|---|---|---|
| committer | shimizukawa <shimizukawa@gmail.com> | 2013-01-21 03:44:31 +0000 |
| commit | 2725068ad0ae80a0d2ee37ad5e81901266f595db (patch) | |
| tree | 0e04b5fde0c1c490bb61c7e873794f49c5dc00bc /sphinx | |
| parent | 1eb2f2dd4b823b8d4ece926951b73a64bf38aa80 (diff) | |
| download | sphinx-2725068ad0ae80a0d2ee37ad5e81901266f595db.tar.gz | |
fix debug2 UnicodeEncodeError issue caused by docutils Element.__repr__() return unicode object if Element['names'] contain unicode object.
This is maybe docutils issue: https://sourceforge.net/tracker/?func=detail&aid=3601607&group_id=38414&atid=422030
Diffstat (limited to 'sphinx')
| -rw-r--r-- | sphinx/application.py | 3 | ||||
| -rw-r--r-- | sphinx/util/nodes.py | 14 |
2 files changed, 15 insertions, 2 deletions
diff --git a/sphinx/application.py b/sphinx/application.py index 5ab55673..c2ebb535 100644 --- a/sphinx/application.py +++ b/sphinx/application.py @@ -343,8 +343,7 @@ class Sphinx(object): event.pop(listener_id, None) def emit(self, event, *args): - args_repr = repr(map(unicode, args))[:100] - self.debug2('[app] emitting event: %s%s', event, args_repr) + self.debug2('[app] emitting event: %r%s', event, repr(args)[:100]) results = [] if event in self._listeners: for _, callback in self._listeners[event].iteritems(): diff --git a/sphinx/util/nodes.py b/sphinx/util/nodes.py index 90e674b6..1d4d3ba5 100644 --- a/sphinx/util/nodes.py +++ b/sphinx/util/nodes.py @@ -233,3 +233,17 @@ def _new_copy(self): return self.__class__(self.rawsource, **self.attributes) nodes.Element.copy = _new_copy + +# monkey-patch Element.__repr__ to return str if include unicode. +# sf.net/tracker/?func=detail&aid=3601607&group_id=38414&atid=422030 +import sys +if sys.version_info < (3,): + _element_repr_orig = nodes.Element.__repr__ + + def _repr(self): + s = _element_repr_orig(self) + if isinstance(s, unicode): + return s.encode('utf-8') + return s + + nodes.Element.__repr__ = _repr |
