René's URL Explorer Experiment


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

direct link

Domain: github.com

route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:7674aa5c-72ef-211d-a2f3-cca16874d376
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-idD93A:6BE0D:110D554:16BEDDA:6969981F
html-safe-nonce67411817ebee92ded1e1eb5684b51ae19d5c3f7b2d6e1985aab6c56e6d9be67e
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEOTNBOjZCRTBEOjExMEQ1NTQ6MTZCRUREQTo2OTY5OTgxRiIsInZpc2l0b3JfaWQiOiI0ODgxMjA4MzMwNTU1MDcwNDk1IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmac9755c15bf08b278c9b84b22c2b426b07e29607b1b3f2523ae0342c58818f18fc
hovercard-subject-tagpull_request:167324190
github-keyboard-shortcutsrepository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///pull_requests/show/files
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/python/cpython/pull/5561/files
twitter:imagehttps://avatars.githubusercontent.com/u/425260?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/425260?s=400&v=4
og:image:altThe 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_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
None3542e147982176a7ebaa23dfb559c8af16f721c03ec560c68c56b64a0f35e751
turbo-cache-controlno-preview
diff-viewunified
go-importgithub.com/python/cpython git https://github.com/python/cpython.git
octolytics-dimension-user_id1525981
octolytics-dimension-user_loginpython
octolytics-dimension-repository_id81598961
octolytics-dimension-repository_nwopython/cpython
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id81598961
octolytics-dimension-repository_network_root_nwopython/cpython
turbo-body-classeslogged-out env-production page-responsive full-width
disable-turbotrue
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
releaseaf80af7cc9e3de9c336f18b208a600950a3c187c
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/python/cpython/pull/5561/files#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fpull%2F5561%2Ffiles
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub SparkBuild and deploy intelligent appshttps://github.com/features/spark
GitHub ModelsManage and compare promptshttps://github.com/features/models
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
GitHub SponsorsFund open source developershttps://github.com/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/accelerator
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://github.com/security/advanced-security
Copilot for BusinessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fpull%2F5561%2Ffiles
Sign up https://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fpull_requests%2Fshow%2Ffiles&source=header-repo&source_repo=python%2Fcpython
Reloadhttps://github.com/python/cpython/pull/5561/files
Reloadhttps://github.com/python/cpython/pull/5561/files
Reloadhttps://github.com/python/cpython/pull/5561/files
python https://github.com/python
cpythonhttps://github.com/python/cpython
Please reload this pagehttps://github.com/python/cpython/pull/5561/files
Notifications https://github.com/login?return_to=%2Fpython%2Fcpython
Fork 33.9k https://github.com/login?return_to=%2Fpython%2Fcpython
Star 71.1k https://github.com/login?return_to=%2Fpython%2Fcpython
Code https://github.com/python/cpython
Issues 5k+ https://github.com/python/cpython/issues
Pull requests 2.1k https://github.com/python/cpython/pulls
Actions https://github.com/python/cpython/actions
Projects 31 https://github.com/python/cpython/projects
Security Uh oh! There was an error while loading. Please reload this page. https://github.com/python/cpython/security
Please reload this pagehttps://github.com/python/cpython/pull/5561/files
Insights https://github.com/python/cpython/pulse
Code https://github.com/python/cpython
Issues https://github.com/python/cpython/issues
Pull requests https://github.com/python/cpython/pulls
Actions https://github.com/python/cpython/actions
Projects https://github.com/python/cpython/projects
Security https://github.com/python/cpython/security
Insights https://github.com/python/cpython/pulse
Sign up for GitHub https://github.com/signup?return_to=%2Fpython%2Fcpython%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://github.com/login?return_to=%2Fpython%2Fcpython%2Fissues%2Fnew%2Fchoose
mdickinsonhttps://github.com/mdickinson
python:mainhttps://github.com/python/cpython/tree/main
eric-wieser:ctypes-paddinghttps://github.com/eric-wieser/cpython/tree/ctypes-padding
Conversation 37 https://github.com/python/cpython/pull/5561
Commits 10 https://github.com/python/cpython/pull/5561/commits
Checks 0 https://github.com/python/cpython/pull/5561/checks
Files changed https://github.com/python/cpython/pull/5561/files
Please reload this pagehttps://github.com/python/cpython/pull/5561/files
gh-76961: Fix the PEP3118 format string for ctypes.Structure https://github.com/python/cpython/pull/5561/files#top
Show all changes 10 commits https://github.com/python/cpython/pull/5561/files
ac4e5bb bpo-32780: Fix the PEP3118 format string for ctypes.Structure eric-wieser Feb 6, 2018 https://github.com/python/cpython/pull/5561/commits/ac4e5bb97625c4f3c545911de31de19baa36caed
e6021e1 Merge branch 'master' into ctypes-padding eric-wieser Nov 28, 2019 https://github.com/python/cpython/pull/5561/commits/e6021e1add19b308d7326e92e77d9745786a4cc3
97e9d95 Merge remote-tracking branch 'upstream/main' into ctypes-padding eric-wieser Jul 7, 2022 https://github.com/python/cpython/pull/5561/commits/97e9d9513aab837e92d620593fc2f9a3f7be9c3b
6bf5a25 remove unused variable, extend documentation eric-wieser Jul 8, 2022 https://github.com/python/cpython/pull/5561/commits/6bf5a25bcb3ac61938570aaf45b698ef28fea4d4
3b7f14f comment eric-wieser Jul 8, 2022 https://github.com/python/cpython/pull/5561/commits/3b7f14fb2530cf569187d882eb24255e3ba56189
27b1601 fix incorrect name and documentation eric-wieser Aug 15, 2022 https://github.com/python/cpython/pull/5561/commits/27b1601038a87f76f32bffbabf1877ff9345a520
e300e16 remove the heap allocation as requested eric-wieser Aug 15, 2022 https://github.com/python/cpython/pull/5561/commits/e300e164394695c5219189fb178cb6849de4754f
7e8b4f9 Merge branch 'main' into ctypes-padding eric-wieser Dec 23, 2022 https://github.com/python/cpython/pull/5561/commits/7e8b4f9cb523f81202065bdeebb19badcf87032d
4de7a8a Update Misc/NEWS.d/next/Core and Builtins/2018-02-05-21-54-46.bpo-327… eric-wieser Feb 5, 2023 https://github.com/python/cpython/pull/5561/commits/4de7a8a2917e8370d2a0a16beeac178a66e74e63
26311ae Apply suggestions from code review eric-wieser Feb 5, 2023 https://github.com/python/cpython/pull/5561/commits/26311aecd38ae115f88b38708bc65eacbbcab651
Clear filters https://github.com/python/cpython/pull/5561/files
Please reload this pagehttps://github.com/python/cpython/pull/5561/files
Please reload this pagehttps://github.com/python/cpython/pull/5561/files
ctypes.rst https://github.com/python/cpython/pull/5561/files#diff-13b210c267218100dc49e485ac4735e44224ae266e36c35f1ac6bf774f59e60d
test_pep3118.py https://github.com/python/cpython/pull/5561/files#diff-4464daec36ba9851ac1a02a8135468fd09e81dbe1fe008f88ec686081ea29bfd
2018-02-05-21-54-46.bpo-32780.Dtiz8z.rst https://github.com/python/cpython/pull/5561/files#diff-afd9dff1729178d0fd058b8e855d0f40b438697534599d706602bb980f372801
stgdict.c https://github.com/python/cpython/pull/5561/files#diff-a75c1edda81c7e4ede83ebbd84c2638023c1b91de15b504f574ba7e08b8b0883
Doc/library/ctypes.rsthttps://github.com/python/cpython/pull/5561/files#diff-13b210c267218100dc49e485ac4735e44224ae266e36c35f1ac6bf774f59e60d
View file https://github.com/eric-wieser/cpython/blob/26311aecd38ae115f88b38708bc65eacbbcab651/Doc/library/ctypes.rst
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/5561/{{ revealButtonHref }}
https://github.com/python/cpython/pull/5561/files#diff-13b210c267218100dc49e485ac4735e44224ae266e36c35f1ac6bf774f59e60d
https://github.com/python/cpython/pull/5561/files#diff-13b210c267218100dc49e485ac4735e44224ae266e36c35f1ac6bf774f59e60d
Lib/test/test_ctypes/test_pep3118.pyhttps://github.com/python/cpython/pull/5561/files#diff-4464daec36ba9851ac1a02a8135468fd09e81dbe1fe008f88ec686081ea29bfd
View file https://github.com/eric-wieser/cpython/blob/26311aecd38ae115f88b38708bc65eacbbcab651/Lib/test/test_ctypes/test_pep3118.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/5561/{{ revealButtonHref }}
https://github.com/python/cpython/pull/5561/files#diff-4464daec36ba9851ac1a02a8135468fd09e81dbe1fe008f88ec686081ea29bfd
https://github.com/python/cpython/pull/5561/files#diff-4464daec36ba9851ac1a02a8135468fd09e81dbe1fe008f88ec686081ea29bfd
https://github.com/python/cpython/pull/5561/files#diff-4464daec36ba9851ac1a02a8135468fd09e81dbe1fe008f88ec686081ea29bfd
https://github.com/python/cpython/pull/5561/files#diff-4464daec36ba9851ac1a02a8135468fd09e81dbe1fe008f88ec686081ea29bfd
Misc/NEWS.d/next/Core and Builtins/2018-02-05-21-54-46.bpo-32780.Dtiz8z.rsthttps://github.com/python/cpython/pull/5561/files#diff-afd9dff1729178d0fd058b8e855d0f40b438697534599d706602bb980f372801
View file https://github.com/eric-wieser/cpython/blob/26311aecd38ae115f88b38708bc65eacbbcab651/Misc/NEWS.d/next/Core%20and%20Builtins/2018-02-05-21-54-46.bpo-32780.Dtiz8z.rst
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/5561/{{ revealButtonHref }}
Modules/_ctypes/stgdict.chttps://github.com/python/cpython/pull/5561/files#diff-a75c1edda81c7e4ede83ebbd84c2638023c1b91de15b504f574ba7e08b8b0883
View file https://github.com/eric-wieser/cpython/blob/26311aecd38ae115f88b38708bc65eacbbcab651/Modules/_ctypes/stgdict.c
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/5561/{{ revealButtonHref }}
https://github.com/python/cpython/pull/5561/files#diff-a75c1edda81c7e4ede83ebbd84c2638023c1b91de15b504f574ba7e08b8b0883
https://github.com/python/cpython/pull/5561/files#diff-a75c1edda81c7e4ede83ebbd84c2638023c1b91de15b504f574ba7e08b8b0883
https://github.com/python/cpython/pull/5561/files#diff-a75c1edda81c7e4ede83ebbd84c2638023c1b91de15b504f574ba7e08b8b0883
https://github.com/python/cpython/pull/5561/files#diff-a75c1edda81c7e4ede83ebbd84c2638023c1b91de15b504f574ba7e08b8b0883
https://github.com/python/cpython/pull/5561/files#diff-a75c1edda81c7e4ede83ebbd84c2638023c1b91de15b504f574ba7e08b8b0883
https://github.com/python/cpython/pull/5561/files#diff-a75c1edda81c7e4ede83ebbd84c2638023c1b91de15b504f574ba7e08b8b0883
https://github.com/python/cpython/pull/5561/files#diff-a75c1edda81c7e4ede83ebbd84c2638023c1b91de15b504f574ba7e08b8b0883
https://github.com/python/cpython/pull/5561/files#diff-a75c1edda81c7e4ede83ebbd84c2638023c1b91de15b504f574ba7e08b8b0883
https://github.com/python/cpython/pull/5561/files#diff-a75c1edda81c7e4ede83ebbd84c2638023c1b91de15b504f574ba7e08b8b0883
https://github.com/python/cpython/pull/5561/files#diff-a75c1edda81c7e4ede83ebbd84c2638023c1b91de15b504f574ba7e08b8b0883
https://github.com/python/cpython/pull/5561/files#diff-a75c1edda81c7e4ede83ebbd84c2638023c1b91de15b504f574ba7e08b8b0883
https://github.com/python/cpython/pull/5561/files#diff-a75c1edda81c7e4ede83ebbd84c2638023c1b91de15b504f574ba7e08b8b0883
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.