fabiommendes / python-boilerplate

Other
76 stars 24 forks source link

Unicode not being parsed in __meta__.py file #3

Open austinkeller opened 8 years ago

austinkeller commented 8 years ago

I'm seeing the following error when trying to run using python 3.5.2. I'm using python-boilerplate 0.4.1. This issue doesn't occur when using python 2.7.12.

(py3) c:\proj\deleteme>python-boilerplate init
Traceback (most recent call last):
  File "c:\users\austin\anaconda2\envs\py3\lib\runpy.py", line 184, in _run_module_as_main
    "__main__", mod_spec)
  File "c:\users\austin\anaconda2\envs\py3\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Users\Austin\Anaconda2\envs\py3\Scripts\python-boilerplate.exe\__main__.py", line 5, in <module>
  File "c:\users\austin\anaconda2\envs\py3\lib\site-packages\python_boilerplate\__init__.py", line 1, in <module>
    from .__meta__ import __author__, __version__
  File "c:\users\austin\anaconda2\envs\py3\lib\site-packages\python_boilerplate\__meta__.py", line 2
SyntaxError: (unicode error) 'utf-8' codec can't decode byte 0xe1 in position 0: unexpected end of data

(py3) c:\proj\deleteme>python --version
Python 3.5.2 :: Continuum Analytics, Inc.

It seems like the __meta__.py file containing your name is being parsed as utf-8 while the file is encoded as latin-1 or some similar encoding.

I'm able to bypass the issue by manually adding the following PEP encoding specifier to the first line in the file: # -*- coding: latin-1 -*-

An alternative might be to save the file as a utf-8 encoded file. I'm unsure which would be a more platform-independent solution...

fabiommendes commented 8 years ago

It is now escaping the unicode characters when saving in the meta.py file. It seems to be the best way to work both on windows/posix and py2/py3. Can you confirm the bug is gone on Windows?