Title: struct: non-ASCII bytes format raises UnicodeEncodeError instead of struct.error on 3.13/3.14 · Issue #158172 · python/cpython · GitHub
Open Graph Title: struct: non-ASCII bytes format raises UnicodeEncodeError instead of struct.error on 3.13/3.14 · Issue #158172 · python/cpython
X Title: struct: non-ASCII bytes format raises UnicodeEncodeError instead of struct.error on 3.13/3.14 · Issue #158172 · python/cpython
Description: Bug report #153835 (backport of gh-85943) introduces a regression on 3.13 and 3.14. A bytes format with a non-ASCII byte now raises UnicodeEncodeError instead of struct.error: >>> import struct >>> struct.unpack(b'\xc5', b'') UnicodeEnco...
Open Graph Description: Bug report #153835 (backport of gh-85943) introduces a regression on 3.13 and 3.14. A bytes format with a non-ASCII byte now raises UnicodeEncodeError instead of struct.error: >>> import struct >>>...
X Description: Bug report #153835 (backport of gh-85943) introduces a regression on 3.13 and 3.14. A bytes format with a non-ASCII byte now raises UnicodeEncodeError instead of struct.error: >>> import s...
Opengraph URL: https://github.com/python/cpython/issues/158172
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"struct: non-ASCII bytes format raises UnicodeEncodeError instead of struct.error on 3.13/3.14","articleBody":"# Bug report\n\nhttps://github.com/python/cpython/pull/153835 (backport of gh-85943) introduces a regression on 3.13 and 3.14. A bytes format with a non-ASCII byte now raises `UnicodeEncodeError` instead of `struct.error`:\n\n```python\n>>> import struct\n>>> struct.unpack(b'\\xc5', b'')\nUnicodeEncodeError: 'ascii' codec can't encode character '\\udcc5' in position 0: ordinal not in range(128)\n```\n\n3.14.0 raises `struct.error: bad char in struct format`. `main` is not affected since gh-145850 already rejects non-ASCII formats with `ValueError`.\n\nThis aborts `fuzz_struct_unpack`, so CIFuzz fails on any 3.14 PR that touches C files, e.g. gh-158162: https://github.com/python/cpython/actions/runs/36136424084/job/108075564322\n\n```\nUnicodeEncodeError: 'ascii' codec can't encode character '\\udcc5' in position 0: ordinal not in range(128)\n==75== ERROR: libFuzzer: deadly signal\n #6 0x55d07f8c7884 in _run_fuzz /src/cpython3/Modules/_xxtestfuzz/fuzzer.c:575:9\n #7 0x55d07f8c7884 in LLVMFuzzerTestOneInput /src/cpython3/Modules/_xxtestfuzz/fuzzer.c:640:11\nBase64: xQA=\n```\n\n\n\u003c!-- gh-linked-prs -->\n### Linked PRs\n* gh-158185\n\u003c!-- /gh-linked-prs -->\n","author":{"url":"https://github.com/corona10","@type":"Person","name":"corona10"},"datePublished":"2026-09-25T14:44:25Z","url":"https://github.com/python/cpython/issues/158172"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react-reconciler,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@d5750093facf |
| 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:e1f553ad-169b-8e1e-d6df-3c70b771affb |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | DBF8:155915:3598F7:494DEB:6AECCB3F |
| html-safe-nonce | 4bd8566b7cd5a47b451774489281de92a2849db6c980664b716859590329c80f |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEQkY4OjE1NTkxNTozNTk4Rjc6NDk0REVCOjZBRUNDQjNGIiwidmlzaXRvcl9pZCI6IjY5MzEwOTAzNjcxOTcyNjg3OTkiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | bf87df1f30e01d8989e08dcdcf77baa0437cf33b34e38a18e78ec706c53cabee |
| hovercard-subject-tag | issue:5584376768 |
| 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/cpython/158172/issue_layout |
| twitter:image | https://opengraph.githubassets.com/7799fabc741efceb189190cd801250cf3b29c450cc3d4a74c9be3a8a7416d7ab/python/cpython/issues/158172 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/7799fabc741efceb189190cd801250cf3b29c450cc3d4a74c9be3a8a7416d7ab/python/cpython/issues/158172 |
| og:image:alt | Bug report #153835 (backport of gh-85943) introduces a regression on 3.13 and 3.14. A bytes format with a non-ASCII byte now raises UnicodeEncodeError instead of struct.error: >>> import struct >>>... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | corona10 |
| hostname | github.com |
| expected-hostname | github.com |
| None | dc0b519c5798dc1150b88dc4c06a8b9634d0069218dc04e469970e76aad74016 |
| turbo-cache-control | no-preview |
| go-import | github.com/python/cpython git https://github.com/python/cpython.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 81598961 |
| octolytics-dimension-repository_nwo | python/cpython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 81598961 |
| octolytics-dimension-repository_network_root_nwo | python/cpython |
| 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 | db139f0bf57b59bf9a8c4abb0849924d6c6ca559 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width