classification
Title: errors in docs re module initialization vs self arg to functions
Type: behavior Stage:
Components: Documentation Versions: Python 3.1
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: georg.brandl Nosy List: aleax, georg.brandl
Priority: normal Keywords: easy

Created on 2009-07-04 22:53 by aleax, last changed 2009-07-11 10:43 by georg.brandl. This issue is now closed.

Messages (2)
msg90134 - (view) Author: Alex Martelli (aleax) * (Python committer) Date: 2009-07-04 22:53
http://docs.python.org/3.1/c-api/structures.html#PyMethodDef

says (under METH_VARARGS):

"""The first one is the self object for methods; for module functions,
it has the value given to Py_InitModule4 (or NULL if Py_InitModule was
used)."""

Py_InitModule4 is no more, and the first argument is now in fact a 
pointer to the module object. This is quite important, since the module 
object is now crucial for the get-state function that's supposed to 
replace a module's statics!

http://docs.python.org/3.1/extending/extending.html#a-simple-example
is ever wronger, since it says, after presenting spam_system's code:

"""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. """

It will never be NULL; it will point to the module.
msg90413 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2009-07-11 10:43
Fixed both instances in r73943.
History
Date User Action Args
2009-07-11 10:43:18georg.brandlsetstatus: open -> closed
resolution: fixed
messages: + msg90413
2009-07-04 22:53:40aleaxcreate