-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Fix default encoding #670
Fix default encoding #670
Conversation
Thank you for submitting this pull request! We’ll get back to you as soon as we can! |
Hi Nacho @nachoaIvarez! Thank you for this. As you can see, Travis is complaining. It looks like our Python linter isn't liking some aspect of this. Can you please amend this PR with a fix for that? I'm guessing the linter is not liking code mixed-in with the |
This PR is great but what do the community thinks about https://stackoverflow.com/a/17628350/5308363 ? @gfyoung @ScriptTiger && others
|
@nachoaIvarez normally such issue can be fixed with the following (what I'm doing when working with a terminal which is restricted to ASCII data). Linux
Most other UNIX systems(Please replace with your country "code")
Start the script
|
/remind me to close this PR in 3 days if no reply from @nachoaIvarez |
Sorry guys for the late. The World Cup is really having my complete attention 😅. So, what do you want the outcome of all this to be? Should I add a couple of lines to the docs to account for the requirement of Regarding the quote from @funilrys, I want to remember that the code already counts on UTF-8 to be the encoding, given all the I think working-by-default is what we should aim for here, but this is just my opinion. BTW, great work @StevenBlack, I love your project and I'm grateful for your investment in it. |
I agree with Nacho @nachoaIvarez when he says, we want this working by default. Guys (and gals), I have a question for readers outside North America and Western Europe. If we drop support for Python 2.7, to what degree does all this become easier? Deprecating Python 2.7 would certainly shrink and simplify the code in some places... |
Well, we then can merge this. Too bad nobody really answered my question but will get my answer by myself elsewhere ... In my opinion, dropping the support for 2.7 have to be done today or in >= 2 years (cf. https://pythonclock.org/). So it's just a matter of time. I will just point out: https://twitter.com/llanga/status/1009104547866742786 (Take the time to understand both side and you may understand the problem of Python 2 vs Python 3 and Experienced vs Inexperienced users ...) Cheers |
Nissar @funilrys, not merging this with failing lint under Travis. Ping Nacho @nachoaIvarez! |
Great! Submitting the updated PR with linter compliance now. |
Added a new commit to include the |
Travis was still failing on python 3, because the |
So, made a step forward, now python 3 is succesfully reloading Should we leave python 3 alone and do this under the python 2 conditional? Not that of an expert in python honestly, so if someone has a better idea, please let the rest of us know! |
Thanks Nacho @nachoaIvarez for tending to this. Oh the joys of maintaining codebases across incompatible versions. I think we'll drop Python 2.7 support sooner than later. Maybe we abandon this path, and recommend what Nissar @funilrys suggests in this comment above? |
Closing. |
On macOS High Sierra, running built-in python 2.7.10, the script
updateHostsFile.py
throws:This is happening because the program doesn't ensure UTF8 as default, although in some places it's done ad-hoc in the shape of
.decode("UTF-8")
calls.This PR ensures the default encoding is set to UTF8, so it's less likely the program might fail on different environments.
After this change:
![image](https://user-images.githubusercontent.com/7253814/41524262-4066d442-72b3-11e8-8ea6-f9356d80baec.png)
Hope this helps.