diff options
author | Larry Hastings <larry@hastings.org> | 2014-01-19 07:50:21 (GMT) |
---|---|---|
committer | Larry Hastings <larry@hastings.org> | 2014-01-19 07:50:21 (GMT) |
commit | b7ccb204236dca49f3d8d119aa84631f519add09 (patch) | |
tree | 18699632f81936d27c4a4edd1d5346804f5fb466 /Doc/howto | |
parent | b470575e2492349584d9afa2a9d581b58ee92c38 (diff) | |
download | cpython-b7ccb204236dca49f3d8d119aa84631f519add09.zip cpython-b7ccb204236dca49f3d8d119aa84631f519add09.tar.gz cpython-b7ccb204236dca49f3d8d119aa84631f519add09.tar.bz2 |
Issue #20294: Argument Clinic now supports argument parsing for __new__ and
__init__ functions.
Diffstat (limited to 'Doc/howto')
-rw-r--r-- | Doc/howto/clinic.rst | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/Doc/howto/clinic.rst b/Doc/howto/clinic.rst index 1f96e82..5ee6c3d 100644 --- a/Doc/howto/clinic.rst +++ b/Doc/howto/clinic.rst @@ -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 ---------------------------------------------- |