Title: gh-76961: Fix the PEP3118 format string for ctypes.Structure by eric-wieser · Pull Request #5561 · python/cpython · GitHub
Open Graph Title: gh-76961: Fix the PEP3118 format string for ctypes.Structure by eric-wieser · Pull Request #5561 · python/cpython
X Title: gh-76961: Fix the PEP3118 format string for ctypes.Structure by eric-wieser · Pull Request #5561 · python/cpython
Description: The summary of this diff is that it: adds a _ctypes_alloc_format_padding function to append strings like 37x to a format string to indicate 37 padding bytes removes the branches that amount to "give up on producing a valid format string if the struct is packed" combines the resulting adjacent if (isStruct) {s now that neither is if (isStruct && !isPacked) { invokes _ctypes_alloc_format_padding to add padding between structure fields, and after the last structure field. The computation used for the total size is unchanged from ctypes already used. This patch does not affect any existing aligment computation; all it does is use subtraction to deduce the amount of paddnig introduced by the existing code. Without this fix, it would never include padding bytes - an assumption that was only valid in the case when _pack_ was set - and this case was explicitly not implemented. This should allow conversion from ctypes structs to numpy structs Fixes numpy/numpy#10528 https://bugs.python.org/issue32780 Fixes #76961 Issue: gh-76961
Open Graph Description: The summary of this diff is that it: adds a _ctypes_alloc_format_padding function to append strings like 37x to a format string to indicate 37 padding bytes removes the branches that amount to &qu...
X Description: The summary of this diff is that it: adds a _ctypes_alloc_format_padding function to append strings like 37x to a format string to indicate 37 padding bytes removes the branches that amount to &am...
Opengraph URL: https://github.com/python/cpython/pull/5561
X: @github
Domain: github.com
| route-pattern | /:user_id/:repository/pull/:id/checks(.:format) |
| route-controller | pull_requests |
| route-action | checks |
| fetch-nonce | v2:78ebc8a1-8106-ba3f-03f8-334611a303f7 |
| current-catalog-service-hash | 87dc3bc62d9b466312751bfd5f889726f4f1337bdff4e8be7da7c93d6c00a25a |
| request-id | 9974:24A66C:70B29:9847C:69695186 |
| html-safe-nonce | cf571da84613be563d7ae22da8efadd3f8a87b275f39e8464e830a0b439e90c1 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5OTc0OjI0QTY2Qzo3MEIyOTo5ODQ3Qzo2OTY5NTE4NiIsInZpc2l0b3JfaWQiOiIyNDA3NzM5ODk4ODk5MDI2MzEwIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 9f5b9395cd8109300dc7dff881f3e6813a4ead1bb76d74a54a076fce4f2aca95 |
| hovercard-subject-tag | pull_request:167324190 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,checks,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/python/cpython/pull/5561/checks |
| twitter:image | https://avatars.githubusercontent.com/u/425260?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/425260?s=400&v=4 |
| og:image:alt | The summary of this diff is that it: adds a _ctypes_alloc_format_padding function to append strings like 37x to a format string to indicate 37 padding bytes removes the branches that amount to &qu... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 9db5f28da7e24035385d7f349f17890cbe016a939ddd7952be0f07b862094f5a |
| 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 full-width full-width-p-0 |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 4e59fe66217d3c72925af2a341ae3a8f2b5b5b2a |
| ui-target | canary-1 |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width