Title: host_env: Don't truncate two byte wchar_t by joshuamegnauth54 · Pull Request #8296 · RustPython/RustPython · GitHub
Open Graph Title: host_env: Don't truncate two byte wchar_t by joshuamegnauth54 · Pull Request #8296 · RustPython/RustPython
X Title: host_env: Don't truncate two byte wchar_t by joshuamegnauth54 · Pull Request #8296 · RustPython/RustPython
Description: Casting a u32 to a u16 would truncate the value. It's safer to use Wtf8::encode_wide which already handles converting a CodePoint to a u16. I removed vec_into_bytes because it was only used in two places. The function was unsound for T but sound in the way RustPython used it (POD to POD, less strict alignment). AI disclosure: I linted this code with AI. I found this issue by accident while working on another patch in which I introduced a similar mistake. AI caught that mistake, so I linted the original code to cross-check it. I wrote the code myself in both instances. Assisted-by: Codex:gpt-5.4 Closes #xxxx This PR follows our AI policy Summary Fixes wchar_t being truncated from u32 to u16 instead of correctly being encoded. Summary by CodeRabbit Bug Fixes Improved platform-specific handling of wide-character data to provide more consistent text encoding behavior across supported systems. Refactor Simplified internal conversion logic and enabled compile-time evaluation for a character conversion utility.
Open Graph Description: Casting a u32 to a u16 would truncate the value. It's safer to use Wtf8::encode_wide which already handles converting a CodePoint to a u16. I removed vec_into_bytes because it was only used in ...
X Description: Casting a u32 to a u16 would truncate the value. It's safer to use Wtf8::encode_wide which already handles converting a CodePoint to a u16. I removed vec_into_bytes because it was only used...
Opengraph URL: https://github.com/RustPython/RustPython/pull/8296
X: @github
Domain: Github.com
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:0c33558a-e5b2-274e-35a5-a6968451d091 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | A110:37660C:CFB78C:1292304:6A632B46 |
| html-safe-nonce | ae4f14dcaeaa454e2e99772c6d355e4a3b86dedbb523a259514d0ff7e46c22b9 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBMTEwOjM3NjYwQzpDRkI3OEM6MTI5MjMwNDo2QTYzMkI0NiIsInZpc2l0b3JfaWQiOiIxNzQwMDE2Njg3OTE0MzYzNzE4IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 70ffe0233fa06d5f70e2142cfd965ecb25eb92881cde1653e3951c1b37c208f6 |
| hovercard-subject-tag | pull_request:4071365291 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,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/RustPython/RustPython/pull/8296/files |
| twitter:image | https://avatars.githubusercontent.com/u/48846352?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/48846352?s=400&v=4 |
| og:image:alt | Casting a u32 to a u16 would truncate the value. It's safer to use Wtf8::encode_wide which already handles converting a CodePoint to a u16. I removed vec_into_bytes because it was only used in ... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 30c644d502bce6cd2e59f9000b4744f2b64819abea8e8f959b18e3ad793125aa |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/RustPython/RustPython git https://github.com/RustPython/RustPython.git |
| octolytics-dimension-user_id | 39710557 |
| octolytics-dimension-user_login | RustPython |
| octolytics-dimension-repository_id | 135201145 |
| octolytics-dimension-repository_nwo | RustPython/RustPython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 135201145 |
| octolytics-dimension-repository_network_root_nwo | RustPython/RustPython |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 331492a48ebd91d66ef2de38e1901bb911c9fe9b |
| ui-target | canary-1 |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width