Commit b158aa7
committed
Use UTF-8 as default encoding
The default value for the `encoding` paramter of `load_dotenv` and
`dotenv_values` is now `"utf-8"` instead of `None` (which selected the
encoding based on the user's locale). It is passed directly to
`io.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 from `open`'s
default value of `None` for the `encoding` parameter.
The default value of `None` was a source of confusion for some users.
The Flask and Docker Compose projects already use `encoding="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.1 parent a7fe93f commit b158aa7
2 files changed
+56
-11
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
11 | 15 | | |
12 | 16 | | |
13 | 17 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
293 | 293 | | |
294 | 294 | | |
295 | 295 | | |
296 | | - | |
297 | | - | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
298 | 305 | | |
299 | 306 | | |
300 | 307 | | |
301 | | - | |
302 | | - | |
303 | | - | |
304 | | - | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
305 | 316 | | |
306 | 317 | | |
307 | | - | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
308 | 325 | | |
309 | 326 | | |
310 | 327 | | |
311 | | - | |
312 | | - | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
313 | 348 | | |
314 | | - | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
0 commit comments