bamos / cv

http://bamos.github.io
MIT License
403 stars 145 forks source link

UnicodeEncodeError: #9

Closed jetheurer closed 9 years ago

jetheurer commented 9 years ago

I was getting this error:

Traceback (most recent call last):
  File "generate.py", line 289, in <module>
    main()
  File "generate.py", line 284, in main
    process_resume(LATEX_CONTEXT, yaml_data, args.preview)
  File "generate.py", line 255, in process_resume
    context.write_to_outfile(rendered_resume)
  File "generate.py", line 209, in write_to_outfile
    out.write(output_data)
UnicodeEncodeError: 'ascii' codec can't encode character u'\xe9' in position 1387: ordinal not in range(128)

is fixed with:

output_data = output_data.encode('utf-8')
bamos commented 9 years ago

Thanks for the report and fix @jetheurer!

Can you see if it still works for you? I changed the open to binary mode to fix the following error in Arch Linux:

cv(master*)$ m build/cv.md
./generate.py cv.yaml
  + Processing section: interests
  + Processing section: education
  + Processing section: research
  + Processing section: teaching
  + Processing section: publications
  + Processing section: industry
  + Processing section: skills
  + Processing section: honors
Traceback (most recent call last):
  File "./generate.py", line 290, in <module>
    main()
  File "./generate.py", line 285, in main
    process_resume(LATEX_CONTEXT, yaml_data, args.preview)
  File "./generate.py", line 256, in process_resume
    context.write_to_outfile(rendered_resume)
  File "./generate.py", line 210, in write_to_outfile
    out.write(output_data)
TypeError: must be str, not bytes
Makefile:31: recipe for target 'build/cv.md' failed
make: *** [build/cv.md] Error 1
bamos commented 9 years ago

Also @jetheurer - I think this bug was hidden in my system because my LOCALE includes UTF-8. My guess is that your LOCALE doesn't, and I think I've run into this in another project when running code on different computers. Would be nice for Python to tell me about this incompatibility. :-)

~$ echo $LANGUAGE $LC_ALL $LC_CTYPE $LANG
en_US.UTF-8 en_US.UTF-8
bamos commented 9 years ago

@jetheurer - I'm closing this issue because I think this issue is resolved. Ping me if something isn't working for you.

jetheurer commented 9 years ago

ah sorry Brandon, I havent gotten around to checking it yet.

Liz

On Mon, Mar 9, 2015 at 10:41 AM, Brandon Amos notifications@github.com wrote:

Closed #9 https://github.com/bamos/cv/issues/9.

— Reply to this email directly or view it on GitHub https://github.com/bamos/cv/issues/9#event-248718908.