[3.11] gh-107442: Document all valid types for ctypes `_as_parameter_` (GH-107443) (#107718)

(cherry picked from commit 6925c578a0)

Co-authored-by: Tomas R <tomas.roun8@gmail.com>
This commit is contained in:
Tomas R 2023-08-07 16:42:19 +02:00 committed by GitHub
parent d58c74c335
commit 880670a34f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 3 deletions

View File

@ -399,9 +399,10 @@ Calling functions with your own custom data types
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
You can also customize :mod:`ctypes` argument conversion to allow instances of
your own classes be used as function arguments. :mod:`ctypes` looks for an
:attr:`_as_parameter_` attribute and uses this as the function argument. Of
course, it must be one of integer, string, or bytes::
your own classes be used as function arguments. :mod:`ctypes` looks for an
:attr:`!_as_parameter_` attribute and uses this as the function argument. The
attribute must be an integer, string, bytes, a :mod:`ctypes` instance, or an
object with an :attr:`!_as_parameter_` attribute::
>>> class Bottles:
... def __init__(self, number):