Preserve nonconsecutive repeated comment lines - #1348
Open
berkay-byte wants to merge 1 commit into
Open
berkay-byte wants to merge 1 commit into
berkay-byte wants to merge 1 commit into
Conversation
akx
requested changes
Sep 18, 2026
akx
left a comment
Member
There was a problem hiding this comment.
While I don't know the rationale for the "only write unique comments" commit from nearly 20 years ago fdb3468, I think there may have been something to it.
To fix the issue in #417, namely
#. KEY:
#. foo.bar.baz...<long words more>...
#. KEY:
#. waldo.fred.plugh...<long words more>...
losing the second KEY:, I think a better patch would be to adjust Message.__init__() to keep only one copy of the same line repeated. What do you think?
berkay-byte
force-pushed
the
fix-po-duplicate-comment-lines
branch
from
September 18, 2026 14:23
8bfa0a8 to
155c599
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #417.
Two long comments beginning with
KEY:can wrap onto separate lines when written to a PO file. Reading that file removes the secondKEY:becauseMessage.__init__()deduplicates comments across the entire list.Use
itertools.groupbyinMessage.__init__()to collapse only consecutive identical comments. Repeated lines separated by other text keep their positions. Both extracted and translator comments follow this rule, including when messages are cloned. PO parsing continues to use the constructor normally.Tests cover consecutive and separated repeats, empty comments, iterator inputs, cloning, obsolete PO entries, and wrapped-comment round trips. Existing catalog-merge deduplication remains unchanged.
Prepared with OpenAI Codex assistance.
Validation: 7,844 tests passed, 9 skipped, 2 expected failures on Python 3.14. Repository pre-commit checks passed for the changed files.