Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problems with code that outputs unicode #18

Closed
petercorke opened this issue Oct 21, 2020 · 1 comment
Closed

Problems with code that outputs unicode #18

petercorke opened this issue Oct 21, 2020 · 1 comment

Comments

@petercorke
Copy link

Firstly, this is a really useful tool, and a timely discovery for me. Thanks.

For a function that outputs the unicode symbol for degrees an error is raised

 File ".../opt/miniconda3/envs/dev/lib/python3.8/site-packages/docutils/parsers/rst/states.py", line 2146, in run_directive
   result = directive_instance.run()
 File ".../opt/miniconda3/envs/dev/lib/python3.8/site-packages/sphinx_autorun/__init__.py", line 73, in run
   out = stdout.decode(output_encoding)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc2 in position 186: ordinal not in range(128)

I hacked the offending line, changing 'ascii' to 'UTF-8' and that works fine.

Looking at doing this nicely in conf.py I would have thought that adding

autorun_languages['pycon_output_encoding'] = 'UTF-8'

would do the trick, but I get

NameError: name 'autorun_languages' is not defined

It looks like setup() makes this available, so now I'm confused. All other sphinx extensions and their configuration are working just fine.

It would be good to document this encoding option.

@petercorke
Copy link
Author

Solved!

autorun_languages = {}
autorun_languages['pycon_output_encoding'] = 'UTF-8'

does the trick. I thought the dict was already created, just need to initialise it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant