Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
e8068e0
Docs: Add missing markup to Argument Clinic docs
erlend-aasland Jul 18, 2023
cf66105
Add missing colon
erlend-aasland Jul 18, 2023
cd940e2
Pull in main
erlend-aasland Jul 19, 2023
6e5c44f
Address reviews
erlend-aasland Jul 19, 2023
d1627ae
Pull in main
erlend-aasland Jul 19, 2023
8f23956
Use :data: for METH_O and METH_NOARGS
erlend-aasland Jul 19, 2023
b155e38
For now, disable the METH_METHOD link
erlend-aasland Jul 19, 2023
971c058
Suggest 'make clinic' and 'make regen-global-objects' iso. running cl…
erlend-aasland Jul 19, 2023
bc33f97
Markup file suffixes and file paths with :file:
erlend-aasland Jul 19, 2023
f5bb4a3
Address review: rewrite line 919 similar to suggestion by Serhiy
erlend-aasland Jul 19, 2023
f892322
fixup! Suggest 'make clinic' and 'make regen-global-objects' iso. run…
erlend-aasland Jul 19, 2023
d96fdeb
Address review: markup more params with **
erlend-aasland Jul 19, 2023
f593853
Pull in main
erlend-aasland Jul 20, 2023
47061df
Address review: revert :program: markups
erlend-aasland Jul 20, 2023
ec6fc6c
Pull in main
erlend-aasland Jul 21, 2023
fe52717
Address review: fix 'int' markup around line 1330
erlend-aasland Jul 21, 2023
1a30f3b
Address review: use new and correct directives for C constants/macros
erlend-aasland Jul 21, 2023
8c69e70
Pull in main
erlend-aasland Jul 22, 2023
499ed66
Revert module.class markup
erlend-aasland Jul 22, 2023
d2f968a
Revert 'make clinic' changes
erlend-aasland Jul 22, 2023
eaaeb42
Pull in main
erlend-aasland Jul 24, 2023
8454b78
METH_METHOD now has its own anchor
erlend-aasland Jul 24, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Address review: markup more params with **
  • Loading branch information
erlend-aasland committed Jul 19, 2023
commit d96fdebe8f252464eac9bfa6582eed29c54f9f30
36 changes: 18 additions & 18 deletions Doc/howto/clinic.rst
Original file line number Diff line number Diff line change
Expand Up @@ -750,57 +750,57 @@ the same converters.
All arguments to Argument Clinic converters are keyword-only.
All Argument Clinic converters accept the following arguments:

``c_default``
*c_default*
The default value for this parameter when defined in C.
Specifically, this will be the initializer for the variable declared
in the "parse function". See :ref:`the section on default values <default_values>`
for how to use this.
Specified as a string.

``annotation``
*annotation*
The annotation value for this parameter. Not currently supported,
because :pep:`8` mandates that the Python library may not use
annotations.

``unused``
*unused*
Wrap the argument with :c:macro:`Py_UNUSED` in the impl function signature.

In addition, some converters accept additional arguments. Here is a list
of these arguments, along with their meanings:

``accept``
*accept*
A set of Python types (and possibly pseudo-types);
this restricts the allowable Python argument to values of these types.
(This is not a general-purpose facility; as a rule it only supports
specific lists of types as shown in the legacy converter table.)

To accept ``None``, add ``NoneType`` to this set.

``bitwise``
*bitwise*
Only supported for unsigned integers. The native integer value of this
Python argument will be written to the parameter without any range checking,
even for negative values.

``converter``
*converter*
Only supported by the ``object`` converter. Specifies the name of a
:ref:`C "converter function" <o_ampersand>`
to use to convert this object to a native type.

``encoding``
*encoding*
Only supported for strings. Specifies the encoding to use when converting
this string from a Python str (Unicode) value into a C ``char *`` value.


``subclass_of``
*subclass_of*
Only supported for the ``object`` converter. Requires that the Python
value be a subclass of a Python type, as expressed in C.

``type``
*type*
Only supported for the ``object`` and ``self`` converters. Specifies
the C type that will be used to declare the variable. Default value is
``"PyObject *"``.

``zeroes``
*zeroes*
Only supported for strings. If true, embedded NUL bytes (``'\\0'``) are
permitted inside the value. The length of the string will be passed in
to the impl function, just after the string parameter, as a parameter named
Expand Down Expand Up @@ -907,11 +907,11 @@ conversion functions, or types, or strings specifying an encoding.
(But "legacy converters" don't support arguments. That's why we
skipped them for your first function.) The argument you specified
to the format unit is now an argument to the converter; this
argument is either ``converter`` (for ``O&``), ``subclass_of`` (for ``O!``),
or ``encoding`` (for all the format units that start with ``e``).
argument is either *converter* (for ``O&``), *subclass_of* (for ``O!``),
or *encoding* (for all the format units that start with ``e``).

When using ``subclass_of``, you may also want to use the other
custom argument for ``object()``: ``type``, which lets you set the type
When using *subclass_of*, you may also want to use the other
custom argument for ``object()``: *type*, which lets you set the type
actually used for the parameter. For example, if you want to ensure
that the object is a subclass of :c:var:`PyUnicode_Type`, you probably want
to use the converter ``object(type='PyUnicodeObject *', subclass_of='&PyUnicode_Type')``.
Expand Down Expand Up @@ -1186,17 +1186,17 @@ using a default converter. It automatically sets the ``type``
of this parameter to the "pointer to an instance" you specified
when you declared the type. However, you can override
Argument Clinic's converter and specify one yourself.
Just add your own ``self`` parameter as the first parameter in a
Just add your own *self* parameter as the first parameter in a
block, and ensure that its converter is an instance of
``self_converter`` or a subclass thereof.
:class:`!self_converter` or a subclass thereof.

What's the point? This lets you override the type of ``self``,
or give it a different default name.

How do you specify the custom type you want to cast ``self`` to?
If you only have one or two functions with the same type for ``self``,
you can directly use Argument Clinic's existing ``self`` converter,
passing in the type you want to use as the ``type`` parameter::
passing in the type you want to use as the *type* parameter::

/*[clinic input]

Expand All @@ -1211,7 +1211,7 @@ passing in the type you want to use as the ``type`` parameter::

On the other hand, if you have a lot of functions that will use the same
type for ``self``, it's best to create your own converter, subclassing
``self_converter`` but overwriting the ``type`` member::
:class:`!self_converter` but overwriting the :py:attr:`!type` member::

/*[python input]
class PicklerObject_converter(self_converter):
Expand Down