Skip to content

Regression in Babel 2.17.0: pybabel extract drops comments for multi-line strings #1195

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

Open
stitch-martha opened this issue Mar 4, 2025 · 1 comment · May be fixed by #1196
Open

Regression in Babel 2.17.0: pybabel extract drops comments for multi-line strings #1195

stitch-martha opened this issue Mar 4, 2025 · 1 comment · May be fixed by #1196
Assignees

Comments

@stitch-martha
Copy link

Description
After upgrading to Babel 2.17.0, I noticed that pybabel extract no longer respects translator comments (# NOTE:) when the corresponding translatable string spans multiple lines. This was not an issue in Babel 2.16.0, making this a regression.

Steps to Reproduce
Given the following Python code:

'test_string': StringWithMeta(
    # NOTE: Text describing a test string
    string=_(
        'Text string that is on a new line'
    ),
),

Running pybabel extract with Babel 2.17.0 and the parameter --add-comments='NOTE' results in the .pot file missing the comment, whereas in Babel 2.16.0, the comment is correctly extracted.

Expected Behavior
The comment should appear in the .pot file:

#. NOTE: Text describing a test string
msgid "Text string that is on a new line"
msgstr ""

Actual Behavior (Babel 2.17.0 Output)

msgid "Text string that is on a new line"
msgstr ""

The # NOTE: comment is missing.

Additional Findings
Downgrading to Babel 2.16.0 restores the expected behavior.
This only happens when the string spans multiple lines.
Single-line strings still retain their comments.

@akx akx self-assigned this Mar 4, 2025
@akx
Copy link
Member

akx commented Mar 4, 2025

Thanks for the bug report, can repro.

According to git bisect, bef3a73 (so #1126) broke this.

akx added a commit that referenced this issue Mar 4, 2025
akx added a commit that referenced this issue Mar 4, 2025
akx added a commit that referenced this issue Mar 5, 2025
akx added a commit that referenced this issue Apr 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants