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

paver crash if open UTF-8 file on Windows 7 #182

Open
foobarjohnny opened this issue Nov 6, 2017 · 4 comments
Open

paver crash if open UTF-8 file on Windows 7 #182

foobarjohnny opened this issue Nov 6, 2017 · 4 comments
Projects

Comments

@foobarjohnny
Copy link

foobarjohnny commented Nov 6, 2017

[Error description]
run the UTF-8 pavement.py in attached zip file under Python 3.6 on Windows 7, it will cause crash as below :

Traceback (most recent call last):
File "d:\program files\python\python3\lib\runpy.py", line 193, in _run_module_as_main
"main", mod_spec)
File "d:\program files\python\python3\lib\runpy.py", line 85, in run_code
exec(code, run_globals)
File "D:\Program Files\Python\Python3\Scripts\paver.exe_main
.py", line 9, in
File "d:\program files\python\python3\lib\site-packages\paver\tasks.py", line 891, in main
_launch_pavement(args)
File "d:\program files\python\python3\lib\site-packages\paver\tasks.py", line 856, in _launch_pavement
source = pf.read()
UnicodeDecodeError: 'gbk' codec can't decode byte 0xad in position 54: illegal multibyte sequence

[Reason]
On Windows 7, the default encoding of open() is not UTF-8 but the system's code page setting.

[Resolution]
Before

     pf = open(environment.pavement_file)

It should detect the file encoding of <environment.pavement_file>, then use

     pf = open(environment.pavement_file, encoding='<the_correct_encoding>')

to open the file.

pavement.zip

@Almad
Copy link
Member

Almad commented Nov 6, 2017

Thanks for the report! Looks like an easy fix, I'll just try to add a test as well

@Almad Almad added this to In progress in Paver 1.3 Dec 28, 2017
@Almad Almad moved this from In progress to To Do in Paver 1.3 Dec 28, 2017
@dogatana
Copy link
Contributor

Hi, how this is going?

I just start using paver in my environment, Python 3.7 on Windows10, and faces this issue.
Python 3.* uses UTF-8 as the default source code encoding, so UTF-8 seems good.

As a counter measure, I put the magic comment on the top of the pavement.py.
But I'm looking forward for the update.

Thank you in advance!

@Almad
Copy link
Member

Almad commented Aug 18, 2020 via email

@dogatana
Copy link
Contributor

I've replace paver in my environment with

pip install git+https://github.com/paver/paver.git

Now it works fine with Python3 default source encoding, thanks !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Paver 1.3
  
To Do
Development

No branches or pull requests

3 participants