@@ -163,7 +163,8 @@ Let's dive in!
1631631. Find a Python builtin that calls either :c:func: `PyArg_ParseTuple `
164164 or :c:func: `PyArg_ParseTupleAndKeywords `, and hasn't been converted
165165 to work with Argument Clinic yet.
166- For my example I'm using :py:meth: `!_pickle.Pickler.dump `.
166+ For my example I'm using
167+ :py:meth: `_pickle.Pickler.dump <pickle.Pickler.dump> `.
167168
1681692. If the call to the :c:func: `!PyArg_Parse* ` function uses any of the
169170 following format units:
@@ -185,7 +186,7 @@ Let's dive in!
185186 Also, if the function has multiple calls to :c:func: `!PyArg_ParseTuple `
186187 or :c:func: `PyArg_ParseTupleAndKeywords ` where it supports different
187188 types for the same argument, or if the function uses something besides
188- PyArg_Parse functions to parse its arguments, it probably
189+ :c:func: ` ! PyArg_Parse* ` functions to parse its arguments, it probably
189190 isn't suitable for conversion to Argument Clinic. Argument Clinic
190191 doesn't support generic functions or polymorphic parameters.
191192
@@ -577,7 +578,7 @@ Argument Clinic will use that function name for the base (generated) function,
577578then add ``"_impl" `` to the end and use that for the name of the impl function.
578579
579580For example, if we wanted to rename the C function names generated for
580- :py:meth: `! pickle.Pickler.dump `, it'd look like this::
581+ :py:meth: `pickle.Pickler.dump `, it'd look like this::
581582
582583 /*[clinic input]
583584 pickle.Pickler.dump as pickler_dumper
@@ -888,7 +889,7 @@ Just run :program:`Tools/clinic/clinic.py --converters` to see the full list.
888889How to use the ``Py_buffer `` converter
889890--------------------------------------
890891
891- When using the :c:data: ` Py_buffer ` converter
892+ When using the `` Py_buffer ` ` converter
892893(or the ``'s*' ``, ``'w*' ``, ``'*y' ``, or ``'z*' `` legacy converters),
893894you *must * not call :c:func: `PyBuffer_Release ` on the provided buffer.
894895Argument Clinic generates code that does it for you (in the parsing function).
@@ -916,7 +917,7 @@ to use the converter ``object(type='PyUnicodeObject *', subclass_of='&PyUnicode_
916917
917918One possible problem with using Argument Clinic: it takes away some possible
918919flexibility for the format units starting with ``e ``. When writing a
919- :c:func: `PyArg_Parse ` call by hand, you could theoretically decide at runtime what
920+ :c:func: `! PyArg_Parse* ` call by hand, you could theoretically decide at runtime what
920921encoding string to pass in to :c:func: `PyArg_ParseTuple `. But now this string must
921922be hard-coded at Argument-Clinic-preprocessing-time. This limitation is deliberate;
922923it made supporting this format unit much easier, and may allow for future optimizations.
@@ -970,7 +971,7 @@ expression. Currently the following are explicitly supported:
970971* Numeric constants (integer and float)
971972* String constants
972973* ``True ``, ``False ``, and ``None ``
973- * Simple symbolic constants like :py:attr : `sys.maxsize `, which must
974+ * Simple symbolic constants like :py:data : `sys.maxsize `, which must
974975 start with the name of the module
975976
976977(In the future, this may need to get even more elaborate,
@@ -991,7 +992,7 @@ Consider the following example:
991992
992993 foo: Py_ssize_t = sys.maxsize - 1
993994
994- :py:attr : `sys.maxsize ` can have different values on different platforms. Therefore
995+ :py:data : `sys.maxsize ` can have different values on different platforms. Therefore
995996Argument Clinic can't simply evaluate that expression locally and hard-code it
996997in C. So it stores the default in such a way that it will get evaluated at
997998runtime, when the user asks for the function's signature.
@@ -1005,8 +1006,8 @@ attribute called :py:attr:`!max_widgets`, you may simply use it:
10051006 foo: Py_ssize_t = max_widgets
10061007
10071008 If the symbol isn't found in the current module, it fails over to looking in
1008- :py:attr : `sys.modules `. That's how it can find :py:attr : `sys.maxsize ` for example. (Since you
1009- don't know in advance what modules the user will load into their interpreter,
1009+ :py:data : `sys.modules `. That's how it can find :py:data : `sys.maxsize ` for example.
1010+ (Since you don't know in advance what modules the user will load into their interpreter,
10101011it's best to restrict yourself to modules that are preloaded by Python itself.)
10111012
10121013Evaluating default values only at runtime means Argument Clinic can't compute
@@ -1317,48 +1318,61 @@ the converter in Argument Clinic will be passed along to your
13171318There are some additional members of :py:class: `!CConverter ` you may wish
13181319to specify in your subclass. Here's the current list:
13191320
1320- :py:attr: `!type `
1321- The C type to use for this variable.
1322- ``type `` should be a Python string specifying the type, e.g. ``int ``.
1323- If this is a pointer type, the type string should end with ``' *' ``.
1324-
1325- :py:attr: `!default `
1326- The Python default value for this parameter, as a Python value.
1327- Or the magic value ``unspecified `` if there is no default.
1328-
1329- :py:attr: `!py_default `
1330- ``default `` as it should appear in Python code,
1331- as a string.
1332- Or ``None `` if there is no default.
1333-
1334- :py:attr: `!c_default `
1335- ``default `` as it should appear in C code,
1336- as a string.
1337- Or ``None `` if there is no default.
1338-
1339- :py:attr: `!c_ignored_default `
1340- The default value used to initialize the C variable when
1341- there is no default, but not specifying a default may
1342- result in an "uninitialized variable" warning. This can
1343- easily happen when using option groups—although
1344- properly written code will never actually use this value,
1345- the variable does get passed in to the impl, and the
1346- C compiler will complain about the "use" of the
1347- uninitialized value. This value should always be a
1348- non-empty string.
1349-
1350- :py:attr: `!converter `
1351- The name of the C converter function, as a string.
1352-
1353- :py:attr: `!impl_by_reference `
1354- A boolean value. If true,
1355- Argument Clinic will add a ``& `` in front of the name of
1356- the variable when passing it into the impl function.
1357-
1358- :py:attr: `!parse_by_reference `
1359- A boolean value. If true,
1360- Argument Clinic will add a ``& `` in front of the name of
1361- the variable when passing it into :c:func: `PyArg_ParseTuple `.
1321+ .. module :: clinic
1322+
1323+ .. class :: CConverter
1324+
1325+ .. attribute :: type
1326+
1327+ The C type to use for this variable.
1328+ :attr: `!type ` should be a Python string specifying the type,
1329+ e.g. :class: `int `.
1330+ If this is a pointer type, the type string should end with ``' *' ``.
1331+
1332+ .. attribute :: default
1333+
1334+ The Python default value for this parameter, as a Python value.
1335+ Or the magic value ``unspecified `` if there is no default.
1336+
1337+ .. attribute :: py_default
1338+
1339+ :attr: `!default ` as it should appear in Python code,
1340+ as a string.
1341+ Or ``None `` if there is no default.
1342+
1343+ .. attribute :: c_default
1344+
1345+ :attr: `!default ` as it should appear in C code,
1346+ as a string.
1347+ Or ``None `` if there is no default.
1348+
1349+ .. attribute :: c_ignored_default
1350+
1351+ The default value used to initialize the C variable when
1352+ there is no default, but not specifying a default may
1353+ result in an "uninitialized variable" warning. This can
1354+ easily happen when using option groups—although
1355+ properly written code will never actually use this value,
1356+ the variable does get passed in to the impl, and the
1357+ C compiler will complain about the "use" of the
1358+ uninitialized value. This value should always be a
1359+ non-empty string.
1360+
1361+ .. attribute :: converter
1362+
1363+ The name of the C converter function, as a string.
1364+
1365+ .. attribute :: impl_by_reference
1366+
1367+ A boolean value. If true,
1368+ Argument Clinic will add a ``& `` in front of the name of
1369+ the variable when passing it into the impl function.
1370+
1371+ .. attribute :: parse_by_reference
1372+
1373+ A boolean value. If true,
1374+ Argument Clinic will add a ``& `` in front of the name of
1375+ the variable when passing it into :c:func: `PyArg_ParseTuple `.
13621376
13631377
13641378Here's the simplest example of a custom converter, from :source: `Modules/zlibmodule.c `::
0 commit comments