Sphinx 1.1pre, Python 3.1, and encoding of docstrings

Hello everybody,

I am in the process of trying out PyCharm, and have moved my project into it. I am documenting with the above (see subject) configuration. I moved it into PyCharm, and now am trying to build the documentation within PyCharm. While this works perfectly fine when run on the command line, when trying to build from inside PyCharm I always get some encoding error the first time it encounters a non-ASCII character in a docstring of a Python file, while it perfectly well works with non-ASCII chars in the .rst files themselves. I've even changed the encoding manually in the preferences of PyCharm (File Encodings) so that all .py files are set up as UTF-8, but to no avail. Is there any reason why PyCharm has some encoding error when building Sphinx 1.1pre documentation for Python 3(.1) when a source code file's docstring I include with autodoc contains non-ASCII characters?

At least on my machine, I can reproduce this error always: create a new project and set up Sphinx. Create a Python source-code file and put a non-ASCII character into the docstring of a dummy function inside it. Include the docstring with autodoc, e.g., in the default index.rst:

.. automodule:: test

   :members:

Now I alwyas get, for my Sphinx builds, the following output in the PyCharm console:

/System/Library/Frameworks/Python.framework/Versions/3.1/bin/sphinx-build /Users/fleitner/PycharmProjects/Tutorial/doc doc/_build

Running Sphinx v1.1pre

loading pickled environment... done

No builder selected, using default: html

building [html]: targets for 1 source files that are out of date

updating environment: 0 added, 1 changed, 0 removed

reading sources... [100%] index


Sphinx error:

'ascii' codec can't decode byte 0xc3 in position 48: ordinal not in range(128)


Process finished with exit code 1

Any help or suggestions would be greatly appreciated!

Regards,

Florian

3 comments

Hello Florian,

This looks like a bug:

http://youtrack.jetbrains.net/issue/PY-3846

We'll investigate this problem and try to provide a fix in the 1.5.2 update.

I am in the process of trying out PyCharm, and have moved my project

into it. I am documenting with the above (see subject) configuration.

I moved it into PyCharm, and now am trying to build the documentation

within PyCharm. While this works perfectly fine when run on the

command line, when trying to build from inside PyCharm I always get

some encoding error the first time it encounters a non-ASCII character

in a docstring of a Python file, while it perfectly well works with

non-ASCII chars in the .rst files themselves. I've even changed the

encoding manually in the preferences of PyCharm (File Encodings) so

that all .py files are set up as UTF-8, but to no avail. Is there any

reason why PyCharm has some encoding error when building Sphinx 1.1pre

documentation for Python 3(.1) when a source code file's docstring I

include with autodoc contains non-ASCII characters?

At least on my machine, I can reproduce this error always: create a

new project and set up Sphinx. Create a Python source-code file and

put a non-ASCII character into the docstring of a dummy function

inside it. Include the docstring with autodoc, e.g., in the default

index.rst:

. automodule:: test

:members:

Now I alwyas get, for my Sphinx builds, the following output in the

PyCharm console:

/System/Library/Frameworks/Python.framework/Versions/3.1/bin/sphinx-bu

ild /Users/fleitner/PycharmProjects/Tutorial/doc doc/_build

Running Sphinx v1.1pre

loading pickled environment... done

No builder selected, using default: html

building : targets for 1 source files that are out of date

updating environment: 0 added, 1 changed, 0 removed

reading sources... index

Sphinx error:

'ascii' codec can't decode byte 0xc3 in position 48: ordinal not in

range(128)

Process finished with exit code 1

Any help or suggestions would be greatly appreciated!

--

Dmitry Jemerov

Development Lead

JetBrains, Inc.

http://www.jetbrains.com/

"Develop with Pleasure!"

0

Might be the case, yes. If there is anything more I can do to help, let me know. I don't see how, but maybe I can try to "smuggle" the envvar you mention into the run of sphinx-build in PyCharm somehow and see if that would fix the issue? I don't need a work-around right now, as I can fall back to the terminal for building documentation that has the described properties - but I'll definitely look forward to a fix! And, thanks for your fast response!

0

Just to comment: the bugreport says fixed, and I have PyCharm 1.5.2 installed, but the error persists...

0

Please sign in to leave a comment.