classification
Title: PEP 597: logging.fileConfig() uses locale encoding.
Type: Stage: resolved
Components: Library (Lib) Versions: Python 3.10
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: methane, vinay.sajip, vstinner
Priority: normal Keywords: patch

Created on 2021-04-05 04:29 by methane, last changed 2021-04-13 23:33 by methane. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 25273 merged methane, 2021-04-08 06:20
Messages (7)
msg390223 - (view) Author: Inada Naoki (methane) * (Python committer) Date: 2021-04-05 04:29
logging.basicConfig() uses locale encoding when reading config file.

We need to add `encoding=None` parameter and `encoding=io.text_encoding(encoding)` in it.
msg390502 - (view) Author: Inada Naoki (methane) * (Python committer) Date: 2021-04-08 06:13
s/basicConfig/fileConfig/

basicConfig() is fixed by fb7869.
msg390941 - (view) Author: Inada Naoki (methane) * (Python committer) Date: 2021-04-13 09:17
New changeset c2b7a66b91cdb96fbfdb160f96797208ddc5e436 by Inada Naoki in branch 'master':
bpo-43731: Add an `encoding` parameter to logging.fileConfig() (GH-25273)
https://github.com/python/cpython/commit/c2b7a66b91cdb96fbfdb160f96797208ddc5e436
msg390944 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2021-04-13 09:48
> fileConfig(fname, defaults=None, disable_existing_loggers=True, encoding=None)

If "locale" is the intended default, why not being more explicit and use encoding="locale"?
msg390952 - (view) Author: Inada Naoki (methane) * (Python committer) Date: 2021-04-13 10:11
If we use `encoding="locale"` by default, EncodingWarning will be not be emitted  even when user omit `encoding` option.
msg390967 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2021-04-13 14:11
Ah, so you want to emit an EncodingWarning when fileConfig(filename) is called without specifying an encoding, right?
msg391016 - (view) Author: Inada Naoki (methane) * (Python committer) Date: 2021-04-13 23:33
> Ah, so you want to emit an EncodingWarning when fileConfig(filename) is called without specifying an encoding, right?

Yes, but only when the user uses `PYTHONWARNDEFAULTENCODING`.

I already added `export PYTHONWARNDEFAULTENCODING=1` in `.bashrc` in my mac and Linux machine.

In the future, config file should be read with UTF-8 by default.
History
Date User Action Args
2021-04-13 23:33:39methanesetmessages: + msg391016
2021-04-13 14:11:51vstinnersetmessages: + msg390967
2021-04-13 10:11:14methanesetmessages: + msg390952
2021-04-13 09:48:02vstinnersetnosy: + vstinner
messages: + msg390944
2021-04-13 09:17:32methanesetmessages: + msg390941
2021-04-13 09:17:22methanesetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2021-04-08 06:20:02methanesetkeywords: + patch
stage: patch review
pull_requests: + pull_request24009
2021-04-08 06:13:24methanesetmessages: + msg390502
title: PEP 597: logging.basicConfig() uses locale encoding. -> PEP 597: logging.fileConfig() uses locale encoding.
2021-04-05 07:46:45xtreaksetnosy: + vinay.sajip
2021-04-05 04:29:28methanecreate