Skip to content

Read UTF-8 test fixtures with explicit encoding - #3245

Open
ShuQingDollarVoyager wants to merge 1 commit into
modelcontextprotocol:mainfrom
ShuQingDollarVoyager:fix/tests-read-text-utf8
Open

Read UTF-8 test fixtures with explicit encoding#3245
ShuQingDollarVoyager wants to merge 1 commit into
modelcontextprotocol:mainfrom
ShuQingDollarVoyager:fix/tests-read-text-utf8

Conversation

@ShuQingDollarVoyager

Copy link
Copy Markdown

Summary

Fixes #3244.

Two Path.read_text() calls in tests/examples omit the encoding argument, so they decode with the locale preferred encoding - on Windows that is the ANSI code page. On non-Western-locale Windows (e.g. Chinese locale, cp936/GBK) this raises UnicodeDecodeError: tests/examples/conftest.py:41 fails at collection (8 collection errors blocking the whole directory) and tests/examples/test_story_shape.py:30 fails ~70 parametrized tests. CI's windows-latest uses cp1252, which happens to decode the same bytes without raising, so this only reproduces on non-Western locales.

Both files being read (manifest.toml, story sources) are UTF-8 - TOML is UTF-8 by specification - so this passes encoding=utf-8 explicitly at both call sites.

Test plan

  • Before: uv run pytest tests -n auto on Chinese-locale Windows 10 (cp936): 70 failed, 8 collection errors.
  • After: full suite green on the same machine: 5574 passed, 16 skipped, 1 xfailed.

Disclosure

This fix was prepared with AI assistance (Claude Code); I have reviewed and verified the change myself.

🤖 Generated with Claude Code

Path.read_text() without an encoding argument uses the locale
preferred encoding, which on Windows is the ANSI code page (e.g.
GBK on Chinese-locale systems). manifest.toml and the story sources
are UTF-8, so tests/examples failed to collect or run there.

Fixes modelcontextprotocol#3244

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 2 files

Re-trigger cubic

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.

Test suite fails with UnicodeDecodeError on Windows with non-UTF-8 locale: read_text() calls missing encoding

1 participant