Repository navigation
Conversation
The `read_file` template filter read the previous changelog with the locale encoding, while the changelog writer saves it as UTF-8. On Windows with a non-UTF-8 code page (for example cp1252 or cp949), updating a changelog that contains non-ASCII text, such as emoji headings or author names, failed with a UnicodeDecodeError or rewrote the text as mojibake. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
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.
Purpose
On Windows with a non-UTF-8 code page (for example cp1252, or cp949 on Korean Windows), updating an existing changelog that contains non-ASCII text fails or corrupts it. In update mode, the previous changelog is read with the
read_filetemplate filter, which opened the file with the locale encoding, while the changelog writer saves the changelog as UTF-8. Text such as emoji headings or author names then fails withor, with cp1252, is rewritten as mojibake when the bytes happen to decode (
✨becomes✨).Rationale
The writer already uses UTF-8 (
write_text(..., encoding="utf-8")incli/changelog_writer.py, andopen(..., encoding="utf-8")inchangelog/template.py), so the filter now reads the file with the same encoding. On Linux and macOS the locale encoding is usually UTF-8, so nothing changes there.How did you test?
On Windows 11 (cp949), Python 3.12:
test_read_file_reads_utf8_whatever_the_locale_encoding. It writes a UTF-8 changelog that contains✨andŁukasz, which neither cp1252 nor cp949 can decode, and checks thatread_filereturns the text unchanged. It fails without the fix (the error above) and passes with it.pytest tests/unit/semantic_release/changelog/: 138 passed, 7 failed, 15 skipped. The 7 failures are intest_release_notes.pyand also fail without this change on this machine: they expect\r\nline endings and get\n.ruff checkandruff format --checkon the changed files. I did not runmypyor the e2e tests.How to Verify
pytest tests/unit/semantic_release/changelog/test_changelog_context.py -k read_file.src/semantic_release/changelog/context.pyand run it again: the new test fails with aUnicodeDecodeError.PR Completion Checklist
Reviewed & followed the Contributor Guidelines
Changes Implemented & Validation pipeline succeeds
Commits follow the Conventional Commits standard
and are separated into the proper commit type and scope (recommended order: test, build, feat/fix, docs)
Appropriate Unit tests added/updated
Appropriate End-to-End tests added/updated
Appropriate Documentation added/updated and syntax validated for sphinx build (see Contributor Guidelines)
This PR was prepared and opened by Claude Code (claude-opus-5-5), an AI agent, on behalf of the account owner.
🤖 Generated with Claude Code