UnicodeDecodeError when creating man pages from utf-8 encoded file

Stanislav Heller avatarStanislav Heller created an issue

If I try to build man page with sphinx-build -b man from rst file with non-ascii characters (czech language) in title encoded in utf-8 (from file -bi i am getting output text/plain; charset=utf-8), I am getting this error:

# Sphinx version: 1.2b1
# Python version: 2.7.3
# Docutils version: 0.10 release
# Jinja2 version: 2.7
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/sphinx/cmdline.py", line 247, in main
    app.build(force_all, filenames)
  File "/usr/local/lib/python2.7/dist-packages/sphinx/application.py", line 211, in build
  File "/usr/local/lib/python2.7/dist-packages/sphinx/builders/__init__.py", line 206, in build_update
    self.build(['__all__'], to_build)
  File "/usr/local/lib/python2.7/dist-packages/sphinx/builders/__init__.py", line 267, in build
    self.write(docnames, list(updated_docnames), method)
  File "/usr/local/lib/python2.7/dist-packages/sphinx/builders/manpage.py", line 88, in write
    docwriter.write(largetree, destination)
  File "/usr/local/lib/python2.7/dist-packages/docutils/writers/__init__.py", line 80, in write
  File "/usr/local/lib/python2.7/dist-packages/sphinx/writers/manpage.py", line 36, in translate
    self.output = visitor.astext()
  File "/usr/local/lib/python2.7/dist-packages/docutils/writers/manpage.py", line 256, in astext
  File "/usr/local/lib/python2.7/dist-packages/sphinx/writers/manpage.py", line 86, in header
    return tmpl % self._docinfo
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 6: ordinal not in range(128)

In conf.py, i have source_encoding = 'utf-8-sig', have tried both 'utf-8' and 'utf8', nothing works for me.

Comments (4)

  1. Stanislav Heller

    Sorry, while preparing file for reproducing this error, i found that it was my fault. There were non-unicode strings inserted into the man_pages variable in conf.py. I have read the notice about Unicode in conf.py in documentation, but forgot about some hacks i made in my conf.py.

    Now its working fine, no error occurs. Nevermind, thanks a lot for your time + all my apologies.

  2. 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.