mirror of
https://github.com/python/cpython.git
synced 2025-11-02 03:01:58 +00:00
Issue #20294: Argument Clinic now supports argument parsing for __new__ and
__init__ functions.
This commit is contained in:
parent
b470575e24
commit
b7ccb20423
6 changed files with 365 additions and 239 deletions
|
|
@ -784,8 +784,8 @@ Argument Clinic converters. On the left is the legacy converter,
|
|||
on the right is the text you'd replace it with.
|
||||
|
||||
========= =================================================================================
|
||||
``'B'`` ``byte(bitwise=True)``
|
||||
``'b'`` ``byte``
|
||||
``'B'`` ``unsigned_char(bitwise=True)``
|
||||
``'b'`` ``unsigned_char``
|
||||
``'c'`` ``char``
|
||||
``'C'`` ``int(types='str')``
|
||||
``'d'`` ``double``
|
||||
|
|
@ -1275,6 +1275,25 @@ any arguments.
|
|||
You can still use a self converter, a return converter, and specify
|
||||
a ``type`` argument to the object converter for ``METH_O``.
|
||||
|
||||
tp_new and tp_init functions
|
||||
----------------------------------------------
|
||||
|
||||
You can convert ``tp_new`` and ``tp_init``
|
||||
functions. Just name them ``__new__`` or
|
||||
``__init__`` as appropriate. Notes:
|
||||
|
||||
* The function name generated for ``__new__`` doesn't end in ``__new__``
|
||||
like it would by default. It's just the name of the class, converted
|
||||
into a valid C identifier.
|
||||
|
||||
* No ``PyMethodDef`` ``#define`` is generated for these functions.
|
||||
|
||||
* ``__init__`` functions return ``int``, not ``PyObject *``.
|
||||
|
||||
* Argument Clinic supports any signature for these functions, even though
|
||||
the parsing function is required to always take ``args`` and ``kwargs``
|
||||
objects.
|
||||
|
||||
The #ifdef trick
|
||||
----------------------------------------------
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue