Title: `ValueError: stream did not contain valid UTF-8` when checking latin_1 file · Issue #22055 · python/mypy · GitHub
Open Graph Title: `ValueError: stream did not contain valid UTF-8` when checking latin_1 file · Issue #22055 · python/mypy
X Title: `ValueError: stream did not contain valid UTF-8` when checking latin_1 file · Issue #22055 · python/mypy
Description: Crash Report Starting with commit 4c5c588, mypy crashes when checking a file from Pylint's test suite: implicit_str_concat_latin1.py Are non-UTF-8 files still supported? If not, maybe an error message could help users handle the behavior...
Open Graph Description: Crash Report Starting with commit 4c5c588, mypy crashes when checking a file from Pylint's test suite: implicit_str_concat_latin1.py Are non-UTF-8 files still supported? If not, maybe an error mess...
X Description: Crash Report Starting with commit 4c5c588, mypy crashes when checking a file from Pylint's test suite: implicit_str_concat_latin1.py Are non-UTF-8 files still supported? If not, maybe an error ...
Opengraph URL: https://github.com/python/mypy/issues/22055
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"`ValueError: stream did not contain valid UTF-8` when checking latin_1 file","articleBody":"**Crash Report**\n\nStarting with commit 4c5c588a, mypy crashes when checking a file from Pylint's test suite: [implicit_str_concat_latin1.py](https://github.com/pylint-dev/pylint/blob/v4.0.9/tests/functional/i/implicit/implicit_str_concat_latin1.py)\n\nAre non-UTF-8 files still supported? If not, maybe an error message could help users handle the behavior change.\n\n**Traceback**\n\n```python-traceback\nTraceback (most recent call last):\n File \".venv-mypy/bin/mypy\", line 6, in \u003cmodule>\n sys.exit(console_entry())\n File \"mypy/mypy/__main__.py\", line 16, in console_entry\n main()\n File \"mypy/mypy/main.py\", line 167, in main\n res, messages, blockers = run_build(sources, options, fscache, t0, stdout, stderr)\n File \"mypy/mypy/main.py\", line 257, in run_build\n res = build.build(sources, options, None, flush_errors, fscache, stdout, stderr)\n File \"mypy/mypy/build.py\", line 425, in build\n result = build_inner(\n File \"mypy/mypy/build.py\", line 540, in build_inner\n graph = dispatch(sources, manager, stdout, connect_threads)\n File \"mypy/mypy/build.py\", line 4122, in dispatch\n graph = load_graph(sources, manager)\n File \"mypy/mypy/build.py\", line 4355, in load_graph\n manager.parse_all([state for state in new if state.needs_parse])\n File \"mypy/mypy/build.py\", line 1089, in parse_all\n parallel_states[0].parse_file()\n File \"mypy/mypy/build.py\", line 3262, in parse_file\n with self.wrap_context():\n File \"/usr/lib/python3.14/contextlib.py\", line 162, in __exit__\n self.gen.throw(value)\n File \"mypy/mypy/build.py\", line 3094, in wrap_context\n yield\n File \"mypy/mypy/build.py\", line 3270, in parse_file\n self.parse_file_inner(source, raw_data)\n ~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^\n File \"mypy/mypy/build.py\", line 3234, in parse_file_inner\n self.tree = self.manager.parse_file(\n ~~~~~~~~~~~~~~~~~~~~~~~^\n self.id, self.xpath, source, options=self.options, raw_data=raw_data\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n )\n ^\n File \"mypy/mypy/build.py\", line 1282, in parse_file\n tree = parse(source, path, id, self.errors, options=options)\n File \"mypy/mypy/parse.py\", line 40, in parse\n tree, _, _ = mypy.nativeparse.native_parse(\n ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^\n fnam, options, source, skip_function_bodies=strip_function_bodies\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n )\n ^\n File \"mypy/mypy/nativeparse.py\", line 241, in native_parse\n ) = parse_to_binary_ast(filename, options, source, skip_function_bodies)\n ~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n File \"mypy/mypy/nativeparse.py\", line 300, in parse_to_binary_ast\n ast_bytes, errors, ignores, import_bytes, ast_data = ast_serialize.parse(\n ~~~~~~~~~~~~~~~~~~~^\n filename,\n ^^^^^^^^^\n ...\u003c6 lines>...\n cache_version=5,\n ^^^^^^^^^^^^^^^^\n )\n ^\nValueError: stream did not contain valid UTF-8\n```\n\n**To Reproduce**\n1. Download [implicit_str_concat_latin1.py](https://github.com/pylint-dev/pylint/blob/v4.0.9/tests/functional/i/implicit/implicit_str_concat_latin1.py) using GitHub's \"Download raw file\" button (to avoid charset issues)\n2. Run mypy on the file\n\n**Your Environment**\n- Mypy version used: 0861bb64\n- Mypy command-line flags: N/A\n- Mypy configuration options from `mypy.ini` (and other config files): N/A\n- Python version used: 3.14.7\n- Operating system and version: Arch Linux","author":{"url":"https://github.com/correctmost","@type":"Person","name":"correctmost"},"datePublished":"2026-09-27T00:27:57Z","url":"https://github.com/python/mypy/issues/22055"}
| 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:b332b6ce-3283-31ce-c514-cb7ee1f279f5 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A618:308D9D:21A4F17:2DD3280:6B002652 |
| html-safe-nonce | ce31052e7e318b7793528c4174ee7b80e6840d7ec6002e8223ff1b7d5b6f2f8b |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBNjE4OjMwOEQ5RDoyMUE0RjE3OjJERDMyODA6NkIwMDI2NTIiLCJ2aXNpdG9yX2lkIjoiNDM1NDQxMDA2NjA3ODYwNjkzMCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | f2805ba455dbc1d68c6f38b4bb70aece9637f42f281af4da5f0e572033ba14f7 |
| hovercard-subject-tag | issue:5598546951 |
| 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/python/mypy/22055/issue_layout |
| twitter:image | https://opengraph.githubassets.com/d9b3b4120b56b7868c9c95cf9fd9b88002a8c16898b77b8a11d9cbe02f96be76/python/mypy/issues/22055 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/d9b3b4120b56b7868c9c95cf9fd9b88002a8c16898b77b8a11d9cbe02f96be76/python/mypy/issues/22055 |
| og:image:alt | Crash Report Starting with commit 4c5c588, mypy crashes when checking a file from Pylint's test suite: implicit_str_concat_latin1.py Are non-UTF-8 files still supported? If not, maybe an error mess... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | correctmost |
| hostname | github.com |
| expected-hostname | github.com |
| None | 4eb4cba0d69f045374ac15de9666d22b0961e1d555cc3824f36b7734c00c78e0 |
| turbo-cache-control | no-preview |
| go-import | github.com/python/mypy git https://github.com/python/mypy.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 7053637 |
| octolytics-dimension-repository_nwo | python/mypy |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 7053637 |
| octolytics-dimension-repository_network_root_nwo | python/mypy |
| 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 | 44c658b24abf00491fb7ae5f56d42c9f38cbeab2 |
| ui-target | canary-2 |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width