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

UnicodeEncodeError template_path.write_text(TEMPLATE_FILE) #91

Closed
yaseralnajjar opened this issue Dec 13, 2020 · 3 comments
Closed

UnicodeEncodeError template_path.write_text(TEMPLATE_FILE) #91

yaseralnajjar opened this issue Dec 13, 2020 · 3 comments
Assignees

Comments

@yaseralnajjar
Copy link
Contributor

  File "C:\Users\kasse\Desktop\test-django-unicorn\venv\lib\site-packages\django\core\management\base.py", line 330, in run_from_argv
    self.execute(*args, **cmd_options)
  File "C:\Users\kasse\Desktop\test-django-unicorn\venv\lib\site-packages\django\core\management\base.py", line 371, in execute
    output = self.handle(*args, **options)
  File "C:\Users\kasse\Desktop\test-django-unicorn\venv\lib\site-packages\django_unicorn\management\commands\startunicorn.py", line 59, in handle
    template_path.write_text(TEMPLATE_FILE)
  File "C:\Users\kasse\AppData\Local\Programs\Python\Python37\lib\pathlib.py", line 1219, in write_text
    return f.write(data)
  File "C:\Users\kasse\AppData\Local\Programs\Python\Python37\lib\encodings\cp1252.py", line 19, in encode
    return codecs.charmap_encode(input,self.errors,encoding_table)[0]
UnicodeEncodeError: 'charmap' codec can't encode character '\U0001f984' in position 20: character maps to <undefined>

The issue is related to utf-8 on Windows when running the command python manage.py startunicorn hello-world

@adamghill adamghill self-assigned this Dec 13, 2020
@adamghill
Copy link
Owner

Yikes, this is because of the 🦄 in the standard template which I guess isn't handled the same on Windows as it is on OSX. I'm going to remove it since it was just a little silly thing I threw in there.

@yaseralnajjar
Copy link
Contributor Author

yaseralnajjar commented Dec 13, 2020

No worries, I was actually gonna write the fix by adding encoding="utf-8", so that it becomes:

template_path.write_text(TEMPLATE_FILE, encoding="utf-8")

Just run into some other problems with poetry... gonna fix those and submit a pull request.

@adamghill
Copy link
Owner

Adding the encoding would definitely work as well! I just ended up removing it and pushing 0.11.1 to PyPI.

Would love any fixes or PRs you want to throw my way!

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

2 participants