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

cgi uses the locale encoding for log files #85311

Closed
serhiy-storchaka opened this issue Jun 27, 2020 · 7 comments
Closed

cgi uses the locale encoding for log files #85311

serhiy-storchaka opened this issue Jun 27, 2020 · 7 comments
Labels
3.10 only security fixes stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@serhiy-storchaka
Copy link
Member

BPO 41139
Nosy @vsajip, @methane, @ethanfurman, @serhiy-storchaka, @srinivasreddy
PRs
  • bpo-41139: Deprecate cgi.log(). #25625
  • 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-29.02:36:58.896>
    created_at = <Date 2020-06-27.11:30:05.583>
    labels = ['type-bug', 'library', '3.10']
    title = 'cgi uses the locale encoding for log files'
    updated_at = <Date 2021-04-29.02:36:58.895>
    user = 'https://github.com/serhiy-storchaka'

    bugs.python.org fields:

    activity = <Date 2021-04-29.02:36:58.895>
    actor = 'methane'
    assignee = 'none'
    closed = True
    closed_date = <Date 2021-04-29.02:36:58.896>
    closer = 'methane'
    components = ['Library (Lib)']
    creation = <Date 2020-06-27.11:30:05.583>
    creator = 'serhiy.storchaka'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 41139
    keywords = ['patch']
    message_count = 7.0
    messages = ['372462', '372866', '372867', '372870', '372872', '390154', '392276']
    nosy_count = 5.0
    nosy_names = ['vinay.sajip', 'methane', 'ethan.furman', 'serhiy.storchaka', 'thatiparthy']
    pr_nums = ['25625']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue41139'
    versions = ['Python 3.10']

    @serhiy-storchaka
    Copy link
    Member Author

    The cgi module provides undocumented feasibility for logging. cgi.log() formats log message and appends it to the log file with name specified by cgi.logfile if it was not empty before the first use of cgi.log().

    One of problems is that it uses the locale encoding for log file. Therefore the result depends on the locale at the moment of the first use of cgi.log().

    We can fix this by using some fixed encoding (UTF-8). Or maybe just remove this undocumented feature.

    @serhiy-storchaka serhiy-storchaka added 3.8 only security fixes 3.9 only security fixes 3.10 only security fixes type-bug An unexpected behavior, bug, or error labels Jun 27, 2020
    @srinivasreddy
    Copy link
    Mannequin

    srinivasreddy mannequin commented Jul 2, 2020

    I am for keeping this functionality. Unless others in this nosy list think otherwise.

    @ethanfurman
    Copy link
    Member

    Which functionality?

    • cgi.log()

    • opening with current locale

    I don't mind keeping the function, but if the file isn't already opened I think using UTF-8 is an appropriate choice.

    @srinivasreddy
    Copy link
    Mannequin

    srinivasreddy mannequin commented Jul 2, 2020

    My bad. I meant cgi.log(), I pressed submit changes in a hurry.

    +1 for utf-8.

    @serhiy-storchaka
    Copy link
    Member Author

    Available options:

    1. Do nothing (keep cgi.log() and continue to use the default encoding for open()).
    2. Remove cgi.log(). I think that the deprecation period is not needed because the function is not documented, is not imported by star-import, and is not shown in help.
    3. Make cgi.log() using UTF-8 for open(). This may break some existing code if cgi.log() is ever used.
    4. Completely rewrite cgi.log() using the logging module.

    In all options except 2 cgi.log() needs to be documented and advertised as a new feature. And we should ask ourself: do we need this feature? Does it have advantages over the logging package?

    It was more visible in 2.0. But since adding __all__ in 2.1 (in e99d5ea) it is a hidden feature.

    @methane
    Copy link
    Member

    methane commented Apr 3, 2021

    +1 for removing.
    But let's emit DeprecationWarning for now, and remove it later.

    @methane methane added stdlib Python modules in the Lib dir and removed 3.8 only security fixes 3.9 only security fixes labels Apr 3, 2021
    @methane
    Copy link
    Member

    methane commented Apr 29, 2021

    New changeset e52ab42 by Inada Naoki in branch 'master':
    bpo-41139: Deprecate cgi.log() (GH-25625)
    e52ab42

    @methane methane closed this as completed Apr 29, 2021
    @methane methane closed this as completed Apr 29, 2021
    @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 type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    3 participants