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

Encoding varies between systems #48

Open
JojOatXGME opened this issue Nov 17, 2018 · 0 comments
Open

Encoding varies between systems #48

JojOatXGME opened this issue Nov 17, 2018 · 0 comments

Comments

@JojOatXGME
Copy link

JojOatXGME commented Nov 17, 2018

I'm using version 0.9.1 of complexity with Python 3. There is no encoding specified when parsing templates and writeing the result to a file. When no encoding is specified, Python 3 uses a default encoding which depends on the system.¹ This might cause different results on different systems while using the same input. This is a problem because the build of a webseite should not depend on the system it is running on. Also note that complexity already specifies an encoding when using Python 2 in contrast to Python 3.

I noticed the problem as I tried to run my build on a system where ASCII is used as default encoding. I got the following error:

Traceback (most recent call last):
  File "./install", line 27, in <module>
    main()
  File "./install", line 22, in main
    complexity("src/", "www/")
  File "/***/site-packages/complexity/main.py", line 78, in complexity
    generate_html(templates_dir, output_dir, context, unexpanded_templates)
  File "/***/site-packages/complexity/generate.py", line 135, in generate_html
    generate_html_file(template_filepath, output_dir, env, context, force_unexpanded)
  File "/***/site-packages/complexity/generate.py", line 82, in generate_html_file
    fh.write(rendered_html)
UnicodeEncodeError: 'ascii' codec can't encode character '\xfc' in position 1432: ordinal not in range(128)

The behavior can be reproduced by setting an environemt variable as noted in the here.

$ LC_ALL=C.ascii complexity src/

For example, the following template file cannot be encoded as ASCII and will result in the shown error:

“Quoted”
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