Skip to content

Commit 32f565f

Browse files
committed
Support custom converter types and instances in ctypes argtypes
In CPython ctypes, any type or adapter instance implementing from_param is allowed in foreign function argtypes. Previously, RustPython required all argtypes entries to be known ctypes types with a _type_ code or pointer/structure subclasses before from_param was even invoked, and assumed from_param would return an instance matching the argtype class. This caused foreign calls with custom converters (such as rich's WindowsCoordinates NamedTuple returning a COORD structure) to fail with TypeError: Unsupported argument type. - Validate that all items in argtypes define from_param on assignment. - Allow arbitrary custom converter types and instances in argtypes. - Inspect the converted instance's class to support converters returning structures and unions by value or simple types. - Fall back to conv_param for arbitrary converted Python objects. - Wrap conversion failures in ctypes.ArgumentError. Fixes #8341.
1 parent 18fc82b commit 32f565f

2 files changed

Lines changed: 252 additions & 90 deletions

File tree

0 commit comments

Comments
 (0)