@@ -27,7 +27,8 @@ Argument Clinic How-To
27
27
version of Argument Clinic that ships with the next version
28
28
of CPython *could * be totally incompatible and break all your code.
29
29
30
- The Goals Of Argument Clinic
30
+
31
+ The goals of Argument Clinic
31
32
============================
32
33
33
34
Argument Clinic's primary goal
@@ -78,7 +79,7 @@ and it should be able to do many interesting and smart
78
79
things with all the information you give it.
79
80
80
81
81
- Basic Concepts And Usage
82
+ Basic concepts and usage
82
83
========================
83
84
84
85
Argument Clinic ships with CPython; you'll find it in ``Tools/clinic/clinic.py ``.
@@ -141,7 +142,7 @@ For the sake of clarity, here's the terminology we'll use with Argument Clinic:
141
142
a block.)
142
143
143
144
144
- Converting Your First Function
145
+ Converting your first function
145
146
==============================
146
147
147
148
The best way to get a sense of how Argument Clinic works is to
@@ -558,7 +559,8 @@ Let's dive in!
558
559
559
560
Congratulations, you've ported your first function to work with Argument Clinic!
560
561
561
- Advanced Topics
562
+
563
+ Advanced topics
562
564
===============
563
565
564
566
Now that you've had some experience working with Argument Clinic, it's time
@@ -636,7 +638,8 @@ after the last argument).
636
638
Currently the generated code will use :c:func: `PyArg_ParseTuple `, but this
637
639
will change soon.
638
640
639
- Optional Groups
641
+
642
+ Optional groups
640
643
---------------
641
644
642
645
Some legacy functions have a tricky approach to parsing their arguments:
@@ -899,6 +902,7 @@ available. For each converter it'll show you all the parameters
899
902
it accepts, along with the default value for each parameter.
900
903
Just run ``Tools/clinic/clinic.py --converters `` to see the full list.
901
904
905
+
902
906
Py_buffer
903
907
---------
904
908
@@ -908,7 +912,6 @@ you *must* not call :c:func:`PyBuffer_Release` on the provided buffer.
908
912
Argument Clinic generates code that does it for you (in the parsing function).
909
913
910
914
911
-
912
915
Advanced converters
913
916
-------------------
914
917
@@ -975,6 +978,7 @@ value called ``NULL`` for just this reason: from Python's perspective it
975
978
behaves like a default value of ``None ``, but the C variable is initialized
976
979
with ``NULL ``.
977
980
981
+
978
982
Expressions specified as default values
979
983
---------------------------------------
980
984
@@ -1032,7 +1036,6 @@ you're not permitted to use:
1032
1036
* Tuple/list/set/dict literals.
1033
1037
1034
1038
1035
-
1036
1039
Using a return converter
1037
1040
------------------------
1038
1041
@@ -1146,6 +1149,7 @@ then modifying it. Cloning is an all-or nothing proposition.
1146
1149
Also, the function you are cloning from must have been previously defined
1147
1150
in the current file.
1148
1151
1152
+
1149
1153
Calling Python code
1150
1154
-------------------
1151
1155
@@ -1380,6 +1384,7 @@ handle initialization and cleanup.
1380
1384
You can see more examples of custom converters in the CPython
1381
1385
source tree; grep the C files for the string ``CConverter ``.
1382
1386
1387
+
1383
1388
Writing a custom return converter
1384
1389
---------------------------------
1385
1390
@@ -1394,8 +1399,9 @@ write your own return converter, please read ``Tools/clinic/clinic.py``,
1394
1399
specifically the implementation of ``CReturnConverter `` and
1395
1400
all its subclasses.
1396
1401
1402
+
1397
1403
METH_O and METH_NOARGS
1398
- ----------------------------------------------
1404
+ ----------------------
1399
1405
1400
1406
To convert a function using ``METH_O ``, make sure the function's
1401
1407
single argument is using the ``object `` converter, and mark the
@@ -1415,8 +1421,9 @@ any arguments.
1415
1421
You can still use a self converter, a return converter, and specify
1416
1422
a ``type `` argument to the object converter for ``METH_O ``.
1417
1423
1424
+
1418
1425
tp_new and tp_init functions
1419
- ----------------------------------------------
1426
+ ----------------------------
1420
1427
1421
1428
You can convert ``tp_new `` and ``tp_init `` functions. Just name
1422
1429
them ``__new__ `` or ``__init__ `` as appropriate. Notes:
@@ -1437,6 +1444,7 @@ them ``__new__`` or ``__init__`` as appropriate. Notes:
1437
1444
(If your function doesn't support keywords, the parsing function
1438
1445
generated will throw an exception if it receives any.)
1439
1446
1447
+
1440
1448
Changing and redirecting Clinic's output
1441
1449
----------------------------------------
1442
1450
@@ -1721,7 +1729,7 @@ the file was not modified by hand before it gets overwritten.
1721
1729
1722
1730
1723
1731
The #ifdef trick
1724
- ----------------------------------------------
1732
+ ----------------
1725
1733
1726
1734
If you're converting a function that isn't available on all platforms,
1727
1735
there's a trick you can use to make life a little easier. The existing
@@ -1801,7 +1809,6 @@ Argument Clinic added to your file (it'll be at the very bottom), then
1801
1809
move it above the ``PyMethodDef `` structure where that macro is used.
1802
1810
1803
1811
1804
-
1805
1812
Using Argument Clinic in Python files
1806
1813
-------------------------------------
1807
1814
0 commit comments