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

"determine_encoding" considered harmful #463

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

smurfix
Copy link
Contributor

@smurfix smurfix commented Dec 14, 2024

There is no reason to assume, in almost-2025, that a Python file is anything but UTF-8.

Thus, always write using the system encoding, which presumably is UTF-8 too.

The removed code causes data loss because if you open a file without UTF-8 codepoints >127 in it, Spyder says that its encoding is ASCII.

If you now add a seemingly-innocous character like an α (a perfectly valid Python variable name) or a comment with a 45° angle in it, you can no longer save the file. You get no error message; the text in the log viewer is easily overlooked, esp. as it doesn't auto-scroll down. Even if you see the error you cannot easily find the problem (where the heck is file position 4867, which character could possibly be 0xB0, and even after I determine that it's a degree sign, how do I find it)?

There is no reason to assume, in almost-2025, that a Python file is
anything but UTF-8.

Thus, always write using the system encoding, which presumably is UTF-8
too.

The removed code causes data loss because if you open a file without
UTF-8 codepoints >127 in it, Spyder says that its encoding is ASCII.

If you now add a seemingly-innocous character like an α (a perfectly
valid Python variable name) or a comment with a 45° angle in it, you can
no longer save the file. You get no error message; the text in
the log viewer is easily overlooked, esp. as it doesn't auto-scroll
down. Even if you see the error you cannot easily find the problem
(where the heck is file position 4867, which character could possibly be
0xB0, and even after I determine that it's a degree sign, how do I
*find* it)?
@jmwright
Copy link
Member

@smurfix Can you merge master into this PR branch and push? That should fix the issues with the tests.

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

Successfully merging this pull request may close these issues.

2 participants