Title: Test suite fails with UnicodeDecodeError on Windows with non-UTF-8 locale: read_text() calls missing encoding · Issue #3244 · modelcontextprotocol/python-sdk · GitHub
Open Graph Title: Test suite fails with UnicodeDecodeError on Windows with non-UTF-8 locale: read_text() calls missing encoding · Issue #3244 · modelcontextprotocol/python-sdk
X Title: Test suite fails with UnicodeDecodeError on Windows with non-UTF-8 locale: read_text() calls missing encoding · Issue #3244 · modelcontextprotocol/python-sdk
Description: Describe the bug On Windows systems where the ANSI code page is not UTF-8 (e.g. Chinese-locale Windows, code page 936 / GBK), running the test suite fails with UnicodeDecodeError in two places: tests/examples/conftest.py:41 - (STORIES_DI...
Open Graph Description: Describe the bug On Windows systems where the ANSI code page is not UTF-8 (e.g. Chinese-locale Windows, code page 936 / GBK), running the test suite fails with UnicodeDecodeError in two places: tes...
X Description: Describe the bug On Windows systems where the ANSI code page is not UTF-8 (e.g. Chinese-locale Windows, code page 936 / GBK), running the test suite fails with UnicodeDecodeError in two places: tes...
Opengraph URL: https://github.com/modelcontextprotocol/python-sdk/issues/3244
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Test suite fails with UnicodeDecodeError on Windows with non-UTF-8 locale: read_text() calls missing encoding","articleBody":"### Describe the bug\n\nOn Windows systems where the ANSI code page is not UTF-8 (e.g. Chinese-locale Windows, code page 936 / GBK), running the test suite fails with `UnicodeDecodeError` in two places:\n\n1. `tests/examples/conftest.py:41` - `(STORIES_DIR / manifest.toml).read_text()` fails during collection (8 collection errors, blocking all of `tests/examples`):\n\n```\ntests\\examples\\conftest.py:41: in \u003cmodule>\n MANIFEST = tomllib.loads((STORIES_DIR / manifest.toml).read_text())\nE UnicodeDecodeError: 'gbk' codec can't decode byte 0x94 in position 441: illegal multibyte sequence\n```\n\n2. `tests/examples/test_story_shape.py:30` - `_parse` reads story sources with `path.read_text()` (~70 test failures once collection succeeds):\n\n```\ntests\\examples\\test_story_shape.py:30: in _parse\n return ast.parse(path.read_text(), filename=str(path))\nE UnicodeDecodeError: 'gbk' codec can't decode byte 0x92 in position 1311: illegal multibyte sequence\n```\n\n`Path.read_text()` without an `encoding` argument uses `locale.getpreferredencoding()`, which is the ANSI code page on Windows (`cp936`/GBK on Chinese-locale systems, `cp1252` on Western-locale systems). The files being read (`manifest.toml`, story sources) are UTF-8 and contain non-ASCII bytes, so decoding fails. CI does not catch this because `windows-latest` runners use cp1252, which happens to decode those byte sequences without raising.\n\n### Expected behavior\n\nThe test suite passes regardless of the host locale. TOML is UTF-8 by specification, and the story sources are UTF-8, so both call sites should pass `encoding=utf-8` explicitly.\n\n### Environment\n\n- OS: Windows 10 (Chinese locale, ANSI code page 936/GBK)\n- Python: 3.11.14\n- SDK: main @ a4f4ccd\n\n### Additional context\n\nFix is two one-line changes adding `encoding=utf-8`; PR to follow.\n\nDisclosure: this bug was found and the fix prepared with AI assistance (Claude Code); the change has been reviewed and verified by me (full suite green on the affected machine: 5574 passed).","author":{"url":"https://github.com/ShuQingDollarVoyager","@type":"Person","name":"ShuQingDollarVoyager"},"datePublished":"2026-08-04T06:52:27Z","url":"https://github.com/modelcontextprotocol/python-sdk/issues/3244"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:723bb434-baf5-de56-79a7-1ce56fc6aafd |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | AFF0:134361:66FACD:89CA63:6B00D3F7 |
| html-safe-nonce | 749a9d0fc2895456e7e30c7efba2819f4f9c1d5ccf56cef0357b8fba90963bdd |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBRkYwOjEzNDM2MTo2NkZBQ0Q6ODlDQTYzOjZCMDBEM0Y3IiwidmlzaXRvcl9pZCI6Ijc3MTMxNzQxMDQ3MjcxNDc1MTEiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 115dd908251d0b9005836f98c2b8daa892f2f7b72f615f73915f8213099aef16 |
| hovercard-subject-tag | issue:5057610353 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/modelcontextprotocol/python-sdk/3244/issue_layout |
| twitter:image | https://opengraph.githubassets.com/03f37a56b4509755a24721b796fdc49c9969cbe2f944feda1d1720b0151e3b45/modelcontextprotocol/python-sdk/issues/3244 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/03f37a56b4509755a24721b796fdc49c9969cbe2f944feda1d1720b0151e3b45/modelcontextprotocol/python-sdk/issues/3244 |
| og:image:alt | Describe the bug On Windows systems where the ANSI code page is not UTF-8 (e.g. Chinese-locale Windows, code page 936 / GBK), running the test suite fails with UnicodeDecodeError in two places: tes... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | ShuQingDollarVoyager |
| hostname | github.com |
| expected-hostname | github.com |
| None | 85bbdfe2b6ba16e234513bc6ceff5d848ef8449820c900692a2b4e67061931e5 |
| turbo-cache-control | no-preview |
| go-import | github.com/modelcontextprotocol/python-sdk git https://github.com/modelcontextprotocol/python-sdk.git |
| octolytics-dimension-user_id | 182288589 |
| octolytics-dimension-user_login | modelcontextprotocol |
| octolytics-dimension-repository_id | 862584018 |
| octolytics-dimension-repository_nwo | modelcontextprotocol/python-sdk |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 862584018 |
| octolytics-dimension-repository_network_root_nwo | modelcontextprotocol/python-sdk |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 4943239a6d2c591325dad6e5c313e1cafda877f6 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width