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

Add explicit encoding in open calls #249

merged 1 commit into from Dec 22, 2021


Copy link

@dlukes dlukes commented Nov 19, 2021

Having enabled PYTHONWARNDEFAULTENCODING on Python 3.10, I now get yelled at (which is a good thing!) whenever Python opens a file in text mode without an encoding specified, implicitly falling back on the locale. It just happened when calling jupyter server --generate-config, so I took a bit of time to add explicit encoding arguments to open calls in jupyter_core.

Please review if UTF-8 is the appropriate encoding in all cases, I'm not otherwise familiar with the codebase, so it's not always easy for me to see. Most of the calls seem to handle Python / CSS / JS files, where UTF-8 should be appropriate, but one of the functions I'm not entirely sure about is paths.secure_write, which can probably be used to write lots of different files (though that in turn means it can be used to write Python files, which should be UTF-8).

Copy link

vidartf commented Dec 21, 2021

This looks like a clear improvement to me.

Copy link

Looks good to me too. Thanks!

@jasongrout jasongrout merged commit 66e16ca into jupyter:master Dec 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
None yet

Successfully merging this pull request may close these issues.

None yet

3 participants