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

PEP 597: logging.fileConfig() uses locale encoding. #87897

Closed
methane opened this issue Apr 5, 2021 · 7 comments
Closed

PEP 597: logging.fileConfig() uses locale encoding. #87897

methane opened this issue Apr 5, 2021 · 7 comments
Labels
3.10 only security fixes stdlib Python modules in the Lib dir

Comments

@methane
Copy link
Member

methane commented Apr 5, 2021

BPO 43731
Nosy @vsajip, @vstinner, @methane
PRs
  • bpo-43731: Add an encoding parameter to logging.fileConfig() #25273
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2021-04-13.09:17:22.309>
    created_at = <Date 2021-04-05.04:29:28.049>
    labels = ['library', '3.10']
    title = 'PEP 597: logging.fileConfig() uses locale encoding.'
    updated_at = <Date 2021-04-13.23:33:39.688>
    user = 'https://github.com/methane'

    bugs.python.org fields:

    activity = <Date 2021-04-13.23:33:39.688>
    actor = 'methane'
    assignee = 'none'
    closed = True
    closed_date = <Date 2021-04-13.09:17:22.309>
    closer = 'methane'
    components = ['Library (Lib)']
    creation = <Date 2021-04-05.04:29:28.049>
    creator = 'methane'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 43731
    keywords = ['patch']
    message_count = 7.0
    messages = ['390223', '390502', '390941', '390944', '390952', '390967', '391016']
    nosy_count = 3.0
    nosy_names = ['vinay.sajip', 'vstinner', 'methane']
    pr_nums = ['25273']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue43731'
    versions = ['Python 3.10']

    @methane
    Copy link
    Member Author

    methane commented Apr 5, 2021

    logging.basicConfig() uses locale encoding when reading config file.

    We need to add encoding=None parameter and encoding=io.text_encoding(encoding) in it.

    @methane methane added 3.10 only security fixes stdlib Python modules in the Lib dir labels Apr 5, 2021
    @methane
    Copy link
    Member Author

    methane commented Apr 8, 2021

    s/basicConfig/fileConfig/

    basicConfig() is fixed by fb7869.

    @methane methane changed the title PEP 597: logging.basicConfig() uses locale encoding. PEP 597: logging.fileConfig() uses locale encoding. Apr 8, 2021
    @methane methane changed the title PEP 597: logging.basicConfig() uses locale encoding. PEP 597: logging.fileConfig() uses locale encoding. Apr 8, 2021
    @methane methane closed this as completed Apr 13, 2021
    @methane methane closed this as completed Apr 13, 2021
    @methane
    Copy link
    Member Author

    methane commented Apr 13, 2021

    New changeset c2b7a66 by Inada Naoki in branch 'master':
    bpo-43731: Add an encoding parameter to logging.fileConfig() (GH-25273)
    c2b7a66

    @vstinner
    Copy link
    Member

    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"?

    @methane
    Copy link
    Member Author

    methane commented Apr 13, 2021

    If we use encoding="locale" by default, EncodingWarning will be not be emitted even when user omit encoding option.

    @vstinner
    Copy link
    Member

    Ah, so you want to emit an EncodingWarning when fileConfig(filename) is called without specifying an encoding, right?

    @methane
    Copy link
    Member Author

    methane commented Apr 13, 2021

    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.

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.10 only security fixes stdlib Python modules in the Lib dir
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants