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:070de02c-500c-1acf-9817-49cd9267db0b |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | DFE0:2A7A96:49527E:60E1FA:6A5BFC88 |
| html-safe-nonce | 268898161e1e34dc7403ecae21082572e4e568851476bc073b79d2e898790c9d |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJERkUwOjJBN0E5Njo0OTUyN0U6NjBFMUZBOjZBNUJGQzg4IiwidmlzaXRvcl9pZCI6IjY2NzE5ODI3NTk4MTU5MzcxNjAiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 2ffd884d0597a7caf91f817191b8011eea6789d71daa39e2de988afa751f06e0 |
| 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 | 5290d7e14309ad1e76106a9c4237bd1041517e83ea182c8ab756752cb0c6940b |
| 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 | 9c975978430e9ad293956f2bbdaf153b1bd84a99 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width