Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e0d9a83

Browse files
committed
Document PyImport_AppendInittab(), PyImport_ExtendInittab(), and
struct _inittab. This closes SourceForge bug #111499.
1 parent 045946d commit e0d9a83

1 file changed

Lines changed: 39 additions & 1 deletion

File tree

Doc/api/api.tex

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1238,7 +1238,7 @@ \section{Importing Modules \label{importing}}
12381238
This is the structure type definition for frozen module descriptors,
12391239
as generated by the \program{freeze}\index{freeze utility} utility
12401240
(see \file{Tools/freeze/} in the Python source distribution). Its
1241-
definition is:
1241+
definition, found in \file{Include/import.h}, is:
12421242

12431243
\begin{verbatim}
12441244
struct _frozen {
@@ -1257,6 +1257,44 @@ \section{Importing Modules \label{importing}}
12571257
dynamically created collection of frozen modules.
12581258
\end{cvardesc}
12591259

1260+
\begin{cfuncdesc}{int}{PyImport_AppendInittab}{char *name,
1261+
void (*initfunc)(void)}
1262+
Add a single module to the existing table of built-in modules. This
1263+
is a convenience wrapper around \cfunction{PyImport_ExtendInittab()},
1264+
returning \code{-1} if the table could not be extended. The new
1265+
module can be imported by the name \var{name}, and uses the function
1266+
\var{initfunc} as the initialization function called on the first
1267+
attempted import. This should be called before
1268+
\cfunction{Py_Initialize()}.
1269+
\end{cfuncdesc}
1270+
1271+
\begin{ctypedesc}[_inittab]{struct _inittab}
1272+
Structure describing a single entry in the list of built-in modules.
1273+
Each of these structures gives the name and initialization function
1274+
for a module built into the interpreter. Programs which embed Python
1275+
may use an array of these structures in conjunction with
1276+
\cfunction{PyImport_ExtendInittab()} to provide additional built-in
1277+
modules. The structure is defined in \file{Include/import.h} as:
1278+
1279+
\begin{verbatim}
1280+
struct _inittab {
1281+
char *name;
1282+
void (*initfunc)(void);
1283+
};
1284+
\end{verbatim}
1285+
\end{ctypedesc}
1286+
1287+
\begin{cfuncdesc}{int}{PyImport_ExtendInittab}{struct _inittab *newtab}
1288+
Add a collection of modules to the table of built-in modules. The
1289+
\var{newtab} array must end with a sentinel entry which contains
1290+
\NULL{} for the \member{name} field; failure to provide the sentinel
1291+
value can result in a memory fault. Returns \code{0} on success or
1292+
\code{-1} if insufficient memory could be allocated to extend the
1293+
internal table. In the event of failure, no modules are added to the
1294+
internal table. This should be called before
1295+
\cfunction{Py_Initialize()}.
1296+
\end{cfuncdesc}
1297+
12601298

12611299
\chapter{Abstract Objects Layer \label{abstract}}
12621300

0 commit comments

Comments
 (0)