Crash, when source fragment in error message contains non-ascii characters

aivarannamaa avataraivarannamaa created an issue

When sphinx-build is invoked with -W, then following mistakes in source cause sphinx to crash instead of displaying nice error message:

Missing empty line:

.. sourcecode:: python
    for i in range(a,b):
        # käsud 

Too short section underline:

Lisanäited
------ 

Stacktrace:

Warning, treated as error:
Traceback (most recent call last):
  File "c:\python27\scripts\sphinx-build-script.py", line 8, in
<module>
    load_entry_point('Sphinx==1.0.7', 'console_scripts', 'sphinx-
build')()
  File "c:\python27\lib\site-packages\sphinx-1.0.7-py2.7.egg\sphinx
\__init__.py"
, line 67, in main
    return cmdline.main(argv)
  File "c:\python27\lib\site-packages\sphinx-1.0.7-py2.7.egg\sphinx
\cmdline.py",
 line 212, in main
    print >>error, err
UnicodeEncodeError: 'ascii' codec can't encode character u'\xe4' in
position 202
: ordinal not in range(128) 

Workaround: change line 212 in cmdline.py from

print >>error, err

to

print >>error, err.message.encode("ascii", "backslashreplace") 

If sphinx-build is invoked without -W, then error message is displayed fine.

Comments (2)

  1. Log in to comment
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.