Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The default value for the
encoding
parameter ofload_dotenv
anddotenv_values
is now"utf-8"
instead ofNone
(which selected the encoding based on the user's locale). It is passed directly toio.open
.The rationale for this change is that the encoding of a project file like
.env
should not depend on the user's locale by default. UTF-8 makes sense as the default encoding since it is also used for Python source files. The main drawback is that it departs fromopen
's default value ofNone
for theencoding
parameter.The default value of
None
was a source of confusion for some users. The Flask and Docker Compose projects already useencoding="utf-8"
to enforce the use of UTF-8 and avoid that sort of confusion.This is a breaking change but only for users with a non-UTF-8 locale and non-UTF-8 characters in their .env files.
Closes #300. Related to issues #205 and #207. Also see PRs #75, #144 and #161 (merged) which suggested using UTF-8.
@theskumar Does this change make sense to you? We initially avoided the breaking change in #161 but I think it could be worth it in the end.