summaryrefslogtreecommitdiff
path: root/sphinx/cmdline.py
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2011-09-21 10:46:39 +0200
committerGeorg Brandl <georg@python.org>2011-09-21 10:46:39 +0200
commit01d0478c41715bffb92ced1a72a68dea261bdcb5 (patch)
treeaa01c2be9eb709a50bc88da2fcbbe759547a6922 /sphinx/cmdline.py
parent5d3736eafd2b3c23bfa8f7835971a0301947478f (diff)
downloadsphinx-01d0478c41715bffb92ced1a72a68dea261bdcb5.tar.gz
Fix #767: safely encode SphinxErrors when printing to sys.stderr.
Diffstat (limited to 'sphinx/cmdline.py')
-rw-r--r--sphinx/cmdline.py10
1 files changed, 5 insertions, 5 deletions
diff --git a/sphinx/cmdline.py b/sphinx/cmdline.py
index af780167..5340aa88 100644
--- a/sphinx/cmdline.py
+++ b/sphinx/cmdline.py
@@ -22,6 +22,7 @@ from sphinx.errors import SphinxError
from sphinx.application import Sphinx
from sphinx.util import Tee, format_exception_cut_frames, save_traceback
from sphinx.util.console import red, nocolor, color_terminal
+from sphinx.util.pycompat import terminal_safe
def usage(argv, msg=None):
@@ -190,8 +191,7 @@ def main(argv):
except KeyboardInterrupt:
if use_pdb:
import pdb
- print >>error, red('Interrupted while building, '
- 'starting debugger:')
+ print >>error, red('Interrupted while building, starting debugger:')
traceback.print_exc()
pdb.post_mortem(sys.exc_info()[2])
return 1
@@ -199,17 +199,17 @@ def main(argv):
if use_pdb:
import pdb
print >>error, red('Exception occurred while building, '
- 'starting debugger:')
+ 'starting debugger:')
traceback.print_exc()
pdb.post_mortem(sys.exc_info()[2])
else:
print >>error
if isinstance(err, SystemMessage):
print >>error, red('reST markup error:')
- print >>error, err.args[0].encode('ascii', 'backslashreplace')
+ print >>error, terminal_safe(err.args[0])
elif isinstance(err, SphinxError):
print >>error, red('%s:' % err.category)
- print >>error, err
+ print >>error, terminal_safe(unicode(err))
else:
print >>error, red('Exception occurred:')
print >>error, format_exception_cut_frames().rstrip()