◐ Shell
reader mode source ↗
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
File filter
Conversations
Jump to
Diff view
Apply and reload
Show whitespace
Diff view
Apply and reload
20 changes: 11 additions & 9 deletions Doc/c-api/import.rst
Original file line number Diff line number Diff line change
Expand Up @@ -283,23 +283,25 @@ Importing Modules

.. c:struct:: _inittab

Structure describing a single entry in the list of built-in modules. Each of
these structures gives the name and initialization function for a module built
into the interpreter. The name is an ASCII encoded string. Programs which
embed Python may use an array of these structures in conjunction with
:c:func:`PyImport_ExtendInittab` to provide additional built-in modules.
The structure is defined in :file:`Include/import.h` as::

struct _inittab {
const char *name; /* ASCII encoded string */
PyObject* (*initfunc)(void);
};


.. c:function:: int PyImport_ExtendInittab(struct _inittab *newtab)

Add a collection of modules to the table of built-in modules. The *newtab*
array must end with a sentinel entry which contains ``NULL`` for the :attr:`name`
field; failure to provide the sentinel value can result in a memory fault.
Returns ``0`` on success or ``-1`` if insufficient memory could be allocated to
extend the internal table. In the event of failure, no modules are added to the
Expand Down
7 changes: 5 additions & 2 deletions Doc/c-api/init.rst
Original file line number Diff line number Diff line change
Expand Up @@ -914,8 +914,11 @@ code, or when embedding the Python interpreter:
.. c:type:: PyThreadState

This data structure represents the state of a single thread. The only public
data member is :attr:`interp` (:c:expr:`PyInterpreterState *`), which points to
this thread's interpreter state.


.. c:function:: void PyEval_InitThreads()
Expand Down
16 changes: 8 additions & 8 deletions Doc/c-api/structures.rst
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ the definition of all other Python objects.

.. c:type:: PyVarObject

This is an extension of :c:type:`PyObject` that adds the :attr:`ob_size`
field. This is only used for objects that have some notion of *length*.
This type does not often appear in the Python/C API.
Access to the members must be done by using the macros
Expand Down Expand Up @@ -171,7 +171,7 @@ the definition of all other Python objects.
.. c:macro:: PyVarObject_HEAD_INIT(type, size)

This is a macro which expands to initialization values for a new
:c:type:`PyVarObject` type, including the :attr:`ob_size` field.
This macro expands to::

_PyObject_EXTRA_INIT
Expand Down Expand Up @@ -247,21 +247,21 @@ Implementing functions and methods
Structure used to describe a method of an extension type. This structure has
four fields:

.. c:member:: const char* ml_name

name of the method

.. c:member:: PyCFunction ml_meth

pointer to the C implementation

.. c:member:: int ml_flags

flags bits indicating how the call should be constructed

.. c:member:: const char* ml_doc

points to the contents of the docstring

The :c:member:`~PyMethodDef.ml_meth` is a C function pointer.
The functions may be of different
Expand Down
3 changes: 2 additions & 1 deletion Doc/c-api/tuple.rst
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,8 @@ type.

Describes a field of a struct sequence. As a struct sequence is modeled as a
tuple, all fields are typed as :c:expr:`PyObject*`. The index in the
:attr:`fields` array of the :c:type:`PyStructSequence_Desc` determines which
field of the struct sequence is described.

+-----------+------------------+-----------------------------------------+
Expand Down
4 changes: 2 additions & 2 deletions Doc/extending/newtypes_tutorial.rst
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,8 @@ Everything else in the file should be familiar, except for some code in
if (PyType_Ready(&CustomType) < 0)
return;

This initializes the :class:`Custom` type, filling in a number of members
to the appropriate default values, including :attr:`ob_type` that we initially
set to ``NULL``. ::

Py_INCREF(&CustomType);
2 changes: 1 addition & 1 deletion Doc/whatsnew/2.5.rst
Original file line number Diff line number Diff line change
Expand Up @@ -954,7 +954,7 @@ The return value must be either a Python integer or long integer. The
interpreter will check that the type returned is correct, and raises a
:exc:`TypeError` if this requirement isn't met.

A corresponding :attr:`nb_index` slot was added to the C-level
:c:type:`PyNumberMethods` structure to let C extensions implement this protocol.
``PyNumber_Index(obj)`` can be used in extension code to call the
:meth:`__index__` function and retrieve its result.
Expand Down
Toggle all file notes Toggle all file annotations