Issue #570 resolved

Unable to pass unicode values via -D command line option

Mikko Värri avatarMikko Värri created an issue

Attached is a small test project that fails with current tip of sphinx (e8018769bc59):

# hg clone https://user@bitbucket.org/birkenfeld/sphinx
# tar sphinx-unicode-argv-test.tar.gz
# cd sphinx-unicode-argv-test
# make clean
# make SPHINX_DIR=../sphinx
PYTHONPATH=../sphinx ../sphinx/sphinx-build.py -W -P -b html -E \
                -D source_suffix=.rst \
                -D master_doc=index \
                -D project=Foo \
                -D version=0.1 \
                -D release=0.1 \
                -D copyright="Mikko Värri" \
                -D html_domain_indices=0 \
                -D html_use_index=0 \
                -D html_show_source_link=0 \
                -D html_use_opensearch='' \
                . ./html
Making output directory...
Running Sphinx v1.1pre/e8018769bc59
building [html]: targets for 1 source files that are out of date
updating environment: 1 added, 0 changed, 0 removed
reading sources... [100%] index                                                                                                                                                                                                                                                        
looking for now-outdated files... none found
pickling environment... done
checking consistency... done
preparing documents... done
Exception occurred while building, starting debugger:                                                                                                                                                                                                                                  
Traceback (most recent call last):
  File "/home/vmj/src/sphinx/sphinx/cmdline.py", line 173, in main
    app.build(force_all, filenames)
  File "/home/vmj/src/sphinx/sphinx/application.py", line 203, in build
    self.builder.build_update()
  File "/home/vmj/src/sphinx/sphinx/builders/__init__.py", line 193, in build_update
    'out of date' % len(to_build))
  File "/home/vmj/src/sphinx/sphinx/builders/__init__.py", line 249, in build
    self.write(docnames, list(updated_docnames), method)
  File "/home/vmj/src/sphinx/sphinx/builders/__init__.py", line 288, in write
    self.write_doc(docname, doctree)
  File "/home/vmj/src/sphinx/sphinx/builders/html.py", line 412, in write_doc
    self.handle_page(docname, ctx, event_arg=doctree)
  File "/home/vmj/src/sphinx/sphinx/builders/html.py", line 712, in handle_page
    "non-ASCII content are Unicode strings." % pagename)
  File "/home/vmj/src/sphinx/sphinx/application.py", line 221, in warn
    raise SphinxWarning(warntext)
SphinxWarning: WARNING: a Unicode error occurred when rendering the page index. Please make sure all config values that contain non-ASCII content are Unicode strings.

> /home/vmj/src/sphinx/sphinx/application.py(221)warn()
-> raise SphinxWarning(warntext)
(Pdb) q

Python version is 2.6.2. Maybe relevant environment variables: LANG=en_US.UTF-8 LC_COLLATE=C. OS: Linux (Slackware64 13.0).

Comments (4)

  1. Mikko Värri

    I have prepared a patch queue that seems to fix it:

    # hg qclone https://user@bitbucket.org/vmj/sphinx-unicode-argv
    # cd sphinx-unicode-argv
    # hg qpush
    # cd ../sphinx-unicode-argv-test
    # make clean
    # make SPHINX_DIR=../sphinx/sphinx-unicode-argv
    PYTHONPATH=../sphinx-unicode-argv ../sphinx-unicode-argv/sphinx-build.py -W -P -b html -E \
                    -D source_suffix=.rst \
                    -D master_doc=index \
                    -D project=Foo \
                    -D version=0.1 \
                    -D release=0.1 \
                    -D copyright="Mikko Värri" \
                    -D html_domain_indices=0 \
                    -D html_use_index=0 \
                    -D html_show_source_link=0 \
                    -D html_use_opensearch='' \
                    . ./html
    Making output directory...
    Running Sphinx v1.1pre/40d369a48cf7
    building [html]: targets for 1 source files that are out of date
    updating environment: 1 added, 0 changed, 0 removed
    reading sources... [100%] index                                                                                                                                                                                                                                                        
    looking for now-outdated files... none found
    pickling environment... done
    checking consistency... done
    preparing documents... done
    writing output... [100%] index                                                                                                                                                                                                                                                         
    writing additional files... search
    copying static files... done
    dumping search index... done
    dumping object inventory... done
    build succeeded.
    
  2. Georg Brandl
    • changed status to open

    Yeah, the cursed command-line argument encoding.

    I'm not really keen on using setlocale() since that has all kinds of other subtle effects on how the process behaves afterwards, but calling getpreferredencoding() without previously calling setlocale() should work too.

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