René's URL Explorer Experiment


Title: Support custom converter types and instances in ctypes argtypes by alok-108 · Pull Request #9685 · RustPython/RustPython · GitHub

Open Graph Title: Support custom converter types and instances in ctypes argtypes by alok-108 · Pull Request #9685 · RustPython/RustPython

X Title: Support custom converter types and instances in ctypes argtypes by alok-108 · Pull Request #9685 · RustPython/RustPython

Description: Closes #8341 One of checkbox below must be checked. I did not use AI to write the code of this patch. This PR follows our AI policy Summary In CPython's ctypes, any object or type with a from_param method can be passed in argtypes. Previously, RustPython required every item in argtypes to be a known ctypes type upfront before calling from_param. Furthermore, when checking whether an argument should be passed as an aggregate by value, it checked whether the converter type itself was a subclass of Structure, rather than checking the type of the converted object. This broke calls that use custom converters (such as rich._win32_console._FillConsoleOutputCharacterW, where WindowsCoordinates is a NamedTuple with a from_param classmethod returning a COORD structure). Changes In extract_arg_types_and_converters, allow arbitrary types/instances as long as they have a from_param method, raising TypeError: item %d in _argtypes_ has no from_param method on AttributeError. Propagate non-AttributeError exceptions directly. In PyCFuncPtrType::init, resolve and store class-level converters in StgInfo when the prototype class is created, matching CPython. In set_argtypes, resolve and cache the validated from_param callables in converters, avoiding repeated descriptor lookups at call time. In extract_call_info, use the cached converters when available to avoid redundant lookups during calls, and synchronize lock acquisition order with set_argtypes. In convert_object, invoke the cached from_param converter directly without rejecting custom converter types or instances upfront. When dispatching structures and unions by value, check the converted object's type (converted.class()) rather than the converter type. Keep converted objects alive across foreign function calls in the conv_param fallback. Wrap conversion errors in ArgumentError: argument %d: ... with the original exception chained via __cause__. In PyCThunk::new, reject non-ctypes classes in callback argtypes. Validation cargo test -p rustpython-vm --lib stdlib::_ctypes::function (passed) cargo run -p rustpython -- extra_tests/snippets/stdlib_ctypes.py (passed) cargo fmt --check and cargo clippy -p rustpython-vm (passed)

Open Graph Description: Closes #8341 One of checkbox below must be checked. I did not use AI to write the code of this patch. This PR follows our AI policy Summary In CPython's ctypes, any object or type with a f...

X Description: Closes #8341 One of checkbox below must be checked. I did not use AI to write the code of this patch. This PR follows our AI policy Summary In CPython's ctypes, any object or type with...

Opengraph URL: https://github.com/RustPython/RustPython/pull/9685

X: @github

direct link

Domain: github.com

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:70be480f-5339-556e-6109-49f2d37d0f65
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-idAA8A:19E4BB:322D57A:4006D17:6B01D7E4
html-safe-nonce8ae42521dfa89243c5bca69ff5530bba3c5501fde346e5f713a2be92f5da92d0
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBQThBOjE5RTRCQjozMjJENTdBOjQwMDZEMTc6NkIwMUQ3RTQiLCJ2aXNpdG9yX2lkIjoiNDQxNjI0NzM1MTY0NDExNjk2NCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmacd28886fa18d5ff601381a9737227e8221036ec0d1bd63352b06cce98927705e6
hovercard-subject-tagpull_request:5147009247
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/RustPython/RustPython/pull/9685/files
twitter:imagehttps://avatars.githubusercontent.com/u/166419621?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/166419621?s=400&v=4
og:image:altCloses #8341 One of checkbox below must be checked. I did not use AI to write the code of this patch. This PR follows our AI policy Summary In CPython's ctypes, any object or type with a f...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
Nonecc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c
turbo-cache-controlno-preview
diff-viewunified
go-importgithub.com/RustPython/RustPython git https://github.com/RustPython/RustPython.git
octolytics-dimension-user_id39710557
octolytics-dimension-user_loginRustPython
octolytics-dimension-repository_id135201145
octolytics-dimension-repository_nwoRustPython/RustPython
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id135201145
octolytics-dimension-repository_network_root_nwoRustPython/RustPython
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
release8c77c9e8439031ad54c75a250694842892f693e1
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/RustPython/RustPython/pull/9685/files#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2FRustPython%2FRustPython%2Fpull%2F9685%2Ffiles
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
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
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://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/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2FRustPython%2FRustPython%2Fpull%2F9685%2Ffiles
Sign uphttps://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=RustPython%2FRustPython
Reloadhttps://github.com/RustPython/RustPython/pull/9685/files
Reloadhttps://github.com/RustPython/RustPython/pull/9685/files
Reloadhttps://github.com/RustPython/RustPython/pull/9685/files
RustPythonhttps://github.com/RustPython
RustPythonhttps://github.com/RustPython/RustPython
Codehttps://github.com/RustPython/RustPython
Issues195 (195)https://github.com/RustPython/RustPython/issues
Pull requests132 (132)https://github.com/RustPython/RustPython/pulls
Discussionshttps://github.com/RustPython/RustPython/discussions
Actionshttps://github.com/RustPython/RustPython/actions
Projectshttps://github.com/RustPython/RustPython/projects
Wikihttps://github.com/RustPython/RustPython/wiki
Security and qualityhttps://github.com/RustPython/RustPython/security
Insightshttps://github.com/RustPython/RustPython/insights
Sign up for GitHub https://github.com/signup?return_to=%2FRustPython%2FRustPython%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://github.com/login?return_to=%2FRustPython%2FRustPython%2Fissues%2Fnew%2Fchoose
alok-108https://github.com/alok-108
RustPython:mainhttps://github.com/RustPython/RustPython/tree/main
alok-108:fix-ctypes-custom-converter-argtypeshttps://github.com/alok-108/RustPython/tree/fix-ctypes-custom-converter-argtypes
Conversation 52 https://github.com/RustPython/RustPython/pull/9685
Commits 3 https://github.com/RustPython/RustPython/pull/9685/commits
Checks 28 https://github.com/RustPython/RustPython/pull/9685/checks
Files changed https://github.com/RustPython/RustPython/pull/9685/files
Please reload this pagehttps://github.com/RustPython/RustPython/pull/9685/files
Support custom converter types and instances in ctypes argtypes https://github.com/RustPython/RustPython/pull/9685/files#top
Show all changes 3 commits https://github.com/RustPython/RustPython/pull/9685/files
580b6da Support custom converter types and instances in ctypes argtypes alok-108 Nov 16, 2026 https://github.com/RustPython/RustPython/pull/9685/commits/580b6dab7c59b325f068fe89592c713bca9a1681
f89960d Store ctypes argtypes and converters separately and convert via ConvP… youknowone Nov 16, 2026 https://github.com/RustPython/RustPython/pull/9685/commits/f89960d1accc8986836e523a2d6b4480fb6b9b58
b448029 Preserve callback array pointer ABI and release class metadata guard alok-108 Nov 16, 2026 https://github.com/RustPython/RustPython/pull/9685/commits/b44802951fd725fa2db76cf1be96543f2505da13
Clear filters https://github.com/RustPython/RustPython/pull/9685/files
Please reload this pagehttps://github.com/RustPython/RustPython/pull/9685/files
Please reload this pagehttps://github.com/RustPython/RustPython/pull/9685/files
base.rs https://github.com/RustPython/RustPython/pull/9685/files#diff-16c64cd355bd8034d61677ad8e407239d548e0e35c48ee05e951e03e93aa1781
function.rs https://github.com/RustPython/RustPython/pull/9685/files#diff-d4cf72f95963a6d3e08f9e7e53594d6b5e2cc7711afbc0b490894d97dc8d8648
simple.rs https://github.com/RustPython/RustPython/pull/9685/files#diff-640c11bed665f401309f30eaa8f59ef7ca4c930c57bc97dbf036e19030e1e64a
stdlib_ctypes.py https://github.com/RustPython/RustPython/pull/9685/files#diff-7cfa080a4c0c0eac19bf2bd0eea152938488bab4c8a8d1b1d7bbc14bce41a61c
crates/vm/src/stdlib/_ctypes/base.rshttps://github.com/RustPython/RustPython/pull/9685/files#diff-16c64cd355bd8034d61677ad8e407239d548e0e35c48ee05e951e03e93aa1781
View file https://github.com/RustPython/RustPython/blob/b44802951fd725fa2db76cf1be96543f2505da13/crates/vm/src/stdlib/_ctypes/base.rs
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/RustPython/RustPython/pull/9685/{{ revealButtonHref }}
https://github.com/RustPython/RustPython/pull/9685/files#diff-16c64cd355bd8034d61677ad8e407239d548e0e35c48ee05e951e03e93aa1781
https://github.com/RustPython/RustPython/pull/9685/files#diff-16c64cd355bd8034d61677ad8e407239d548e0e35c48ee05e951e03e93aa1781
https://github.com/RustPython/RustPython/pull/9685/files#diff-16c64cd355bd8034d61677ad8e407239d548e0e35c48ee05e951e03e93aa1781
https://github.com/RustPython/RustPython/pull/9685/files#diff-16c64cd355bd8034d61677ad8e407239d548e0e35c48ee05e951e03e93aa1781
https://github.com/RustPython/RustPython/pull/9685/files#diff-16c64cd355bd8034d61677ad8e407239d548e0e35c48ee05e951e03e93aa1781
https://github.com/RustPython/RustPython/pull/9685/files#diff-16c64cd355bd8034d61677ad8e407239d548e0e35c48ee05e951e03e93aa1781
https://github.com/RustPython/RustPython/pull/9685/files#diff-16c64cd355bd8034d61677ad8e407239d548e0e35c48ee05e951e03e93aa1781
https://github.com/RustPython/RustPython/pull/9685/files#diff-16c64cd355bd8034d61677ad8e407239d548e0e35c48ee05e951e03e93aa1781
https://github.com/RustPython/RustPython/pull/9685/files#diff-16c64cd355bd8034d61677ad8e407239d548e0e35c48ee05e951e03e93aa1781
Please reload this pagehttps://github.com/RustPython/RustPython/pull/9685/files
Please reload this pagehttps://github.com/RustPython/RustPython/pull/9685/files
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.