diff options
author | Georg Brandl <georg@python.org> | 2010-11-12 19:45:46 (GMT) |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2010-11-12 19:45:46 (GMT) |
commit | 749930f0f026c8751bb216f1923c0b164e32d54a (patch) | |
tree | be261576656020444f772df2f2d14728e6febbb4 /Doc | |
parent | 6e4300c99912b96089b1d8160e4b637a52d88df4 (diff) | |
download | cpython-749930f0f026c8751bb216f1923c0b164e32d54a.zip cpython-749930f0f026c8751bb216f1923c0b164e32d54a.tar.gz cpython-749930f0f026c8751bb216f1923c0b164e32d54a.tar.bz2 |
#10398: manual backport of r73943.
Diffstat (limited to 'Doc')
-rw-r--r-- | Doc/c-api/structures.rst | 16 | ||||
-rw-r--r-- | Doc/extending/extending.rst | 6 |
2 files changed, 9 insertions, 13 deletions
diff --git a/Doc/c-api/structures.rst b/Doc/c-api/structures.rst index 6ef31d2..5be88ac 100644 --- a/Doc/c-api/structures.rst +++ b/Doc/c-api/structures.rst @@ -137,12 +137,10 @@ convention flags can be combined with a binding flag. This is the typical calling convention, where the methods have the type :ctype:`PyCFunction`. The function expects two :ctype:`PyObject\*` values. - The first one is the *self* object for methods; for module functions, it - has the value given to :cfunc:`Py_InitModule4` (or *NULL* if - :cfunc:`Py_InitModule` was used). The second parameter (often called - *args*) is a tuple object representing all arguments. This parameter is - typically processed using :cfunc:`PyArg_ParseTuple` or - :cfunc:`PyArg_UnpackTuple`. + The first one is the *self* object for methods; for module functions, it is + the module object. The second parameter (often called *args*) is a tuple + object representing all arguments. This parameter is typically processed + using :cfunc:`PyArg_ParseTuple` or :cfunc:`PyArg_UnpackTuple`. .. data:: METH_KEYWORDS @@ -158,9 +156,9 @@ convention flags can be combined with a binding flag. Methods without parameters don't need to check whether arguments are given if they are listed with the :const:`METH_NOARGS` flag. They need to be of type - :ctype:`PyCFunction`. When used with object methods, the first parameter is - typically named ``self`` and will hold a reference to the object instance. - In all cases the second parameter will be *NULL*. + :ctype:`PyCFunction`. The first parameter is typically named ``self`` and + will hold a reference to the module or object instance. In all cases the + second parameter will be *NULL*. .. data:: METH_O diff --git a/Doc/extending/extending.rst b/Doc/extending/extending.rst index 2d9594a..ad6a9f3 100644 --- a/Doc/extending/extending.rst +++ b/Doc/extending/extending.rst @@ -89,10 +89,8 @@ example, the single expression ``"ls -l"``) to the arguments passed to the C function. The C function always has two arguments, conventionally named *self* and *args*. -The *self* argument is only used when the C function implements a built-in -method, not a function. In the example, *self* will always be a *NULL* pointer, -since we are defining a function, not a method. (This is done so that the -interpreter doesn't have to understand two different types of C functions.) +The *self* argument points to the module object for module-level functions; +for a method it would point to the object instance. The *args* argument will be a pointer to a Python tuple object containing the arguments. Each item of the tuple corresponds to an argument in the call's |