10000 Incorrect handling for msgctxt in msgfmt.py · Issue #85012 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

Incorrect handling for msgctxt in msgfmt.py #85012

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

Closed
da1910 mannequin opened this issue May 31, 2020 · 5 comments
Closed

Incorrect handling for msgctxt in msgfmt.py #85012

da1910 mannequin opened this issue May 31, 2020 · 5 comments
Assignees
Labels
3.12 only security fixes 3.13 bugs and security fixes 3.14 bugs and security fixes triaged The issue has been accepted as valid by a triager. type-bug An unexpected behavior, bug, or error

Comments

@da1910
Copy link
Mannequin
da1910 mannequin commented May 31, 2020
BPO 40835
Nosy @da1910
Files
  • test.po
  • 40835.patch
  • 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 = None
    created_at = <Date 2020-05-31.20:56:52.559>
    labels = ['type-bug', '3.8']
    title = 'Incorrect handling for msgctxt in msgfmt.py'
    updated_at = <Date 2020-05-31.21:16:05.371>
    user = 'https://github.com/da1910'

    bugs.python.org fields:

    activity = <Date 2020-05-31.21:16:05.371>
    actor = 'da1910'
    assignee = 'none'
    closed = False
    closed_date = None
    closer = None
    components = ['Demos and Tools']
    creation = <Date 2020-05-31.20:56:52.559>
    creator = 'da1910'
    dependencies = []
    files = ['49205', '49206']
    hgrepos = []
    issue_num = 40835
    keywords = ['patch']
    message_count = 3.0
    messages = ['370502', '370504', '370507']
    nosy_count = 1.0
    nosy_names = ['da1910']
    pr_nums = []
    priority = 'normal'
    resolution = None
    stage = None
    status = 'open'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue40835'
    versions = ['Python 3.8']

    Linked PRs

    @da1910
    Copy link
    Mannequin Author
    da1910 mannequin commented May 31, 2020

    Running msgfmt.py with the attached po file will produce an incorrect context for the entry "test".

    Looking at the script, we require a comment to follow a contexted section for the context to be cleared. The gettext documentation makes clear that all comments are optional, so this is not desired behaviour.

    My reading of the gettext documentation has a "msgctxt" line applying only to the current entry, so it should be cleared once the last msgstr has been written for that entry.

    I will endeavour to provide a patch within the next day or two.

    @da1910 da1910 mannequin added 3.8 (EOL) end of life type-bug An unexpected behavior, bug, or error labels May 31, 2020
    @da1910
    Copy link
    Mannequin Author
    da1910 mannequin commented May 31, 2020

    Test po file included

    @da1910
    Copy link
    Mannequin Author
    da1910 mannequin commented May 31, 2020

    And a patch:

    After the end of a message entry the options for the next line are:

    1. A comment - we already reset msgctxt to None here
    2. A blank line - we can have empty lines anywhere we want, so do nothing
    3. A new msgctxt line - Set msgctxt to the new context
    4. A msgid - This is the current failing behaviour. Fix sets msgctxt back to None.

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    @m-aciek
    Copy link
    Contributor
    m-aciek commented Dec 8, 2023

    Does msgfmt.py have its test suite? It would be worth to add also a regression test there.

    @tomasr8
    Copy link
    Member
    tomasr8 commented Dec 8, 2023

    There is Lib/test/test_tools/test_i18n.py for pygettext but no tests for msgfmt as far as I'm aware

    @tomasr8 tomasr8 self-assigned this Feb 16, 2025
    @picnixz picnixz added triaged The issue has been accepted as valid by a triager. and removed 3.8 (EOL) end of life labels Feb 16, 2025
    serhiy-storchaka pushed a commit that referenced this issue Mar 13, 2025
    serhiy-storchaka pushed a commit to serhiy-storchaka/cpython that referenced this issue Mar 13, 2025
    … with msgfmt (pythonGH-130525)
    
    Add also human-readable snapshots for tests.
    (cherry picked from commit 7ea6e88)
    
    Co-authored-by: Tomas R. <tomas.roun8@gmail.com>
    serhiy-storchaka pushed a commit to serhiy-storchaka/cpython that referenced this issue Mar 13, 2025
    … with msgfmt (pythonGH-130525)
    
    Add also human-readable snapshots for tests.
    (cherry picked from commit 7ea6e88)
    
    Co-authored-by: Tomas R. <tomas.roun8@gmail.com>
    @serhiy-storchaka serhiy-storchaka added 3.12 only security fixes 3.13 bugs and security fixes 3.14 bugs and security fixes labels Mar 13, 2025
    serhiy-storchaka added a commit that referenced this issue Mar 13, 2025
    …msgfmt (GH-130525) (GH-131206)
    
    Add also human-readable snapshots for tests.
    (cherry picked from commit 7ea6e88)
    
    Co-authored-by: Tomas R <tomas.roun8@gmail.com>
    serhiy-storchaka added a commit that referenced this issue Mar 13, 2025
    …msgfmt (GH-130525) (GH-131205)
    
    Add also human-readable snapshots for tests.
    (cherry picked from commit 7ea6e88)
    
    Co-authored-by: Tomas R <tomas.roun8@gmail.com>
    mikec9 pushed a commit to mikec9/cpython that referenced this issue Mar 14, 2025
    … with msgfmt (pythonGH-130525) (pythonGH-131206)
    
    Add also human-readable snapshots for tests.
    (cherry picked from commit 7ea6e88)
    
    Co-authored-by: Tomas R <tomas.roun8@gmail.com>
    plashchynski pushed a commit to plashchynski/cpython that referenced this issue Mar 17, 2025
    seehwan pushed a commit to seehwan/cpython that referenced this issue Apr 16, 2025
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.12 only security fixes 3.13 bugs and security fixes 3.14 bugs and security fixes triaged The issue has been accepted as valid by a triager. type-bug An unexpected behavior, bug, or error
    Projects
    Status: Done
    Development

    No branche 320C s or pull requests

    4 participants
    0