Skip to content

🧪 Read the CommonMark spec fixtures as UTF-8 - #454

Open
Aschenbath wants to merge 2 commits into
executablebooks:masterfrom
Aschenbath:fix-spec-test-encoding
Open

Aschenbath wants to merge 2 commits into
executablebooks:masterfrom
Aschenbath:fix-spec-test-encoding

Conversation

@Aschenbath

Copy link
Copy Markdown

On Windows with a non-UTF-8 system locale (here: GBK, Chinese Windows), test collection for tests/test_cmark_spec/test_spec.py fails:

tests\test_cmark_spec\test_spec.py:21: in <module>
    @pytest.mark.parametrize("entry", json.loads(TESTS_INPUT.read_text()))
UnicodeDecodeError: 'gbk' codec can't decode byte 0x8b in position 5396: illegal multibyte sequence

Path.read_text() uses the locale encoding when none is given, but the spec fixtures are UTF-8. This passes encoding="utf-8" to the four read_text() calls in test_spec.py and get_cmark_spec.py. Test-only change.

Verification (Windows 11, Python 3.12, locale cp936):

  • before: collection error, 379 passed / 8 errors
  • after: pytest tests → 1032 passed (same result as running with PYTHONUTF8=1)

Disclosure: this fix was found and written with an AI coding assistant (Claude Code) and verified by running the test suite as above.

🤖 Generated with Claude Code

Aschenbath and others added 2 commits November 3, 2026 21:11
`test_spec.py` and `get_cmark_spec.py` call `Path.read_text()` without an
encoding, so on Windows with a non-UTF-8 locale (e.g. GBK on Chinese
Windows) collecting the spec tests fails with UnicodeDecodeError and the
whole module errors out. The fixtures are UTF-8, so read them as such.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant