Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
483d6c50
Commit
483d6c50
authored
Dec 09, 2008
by
Georg Brandl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#4592: fix embedding example with new C API changes.
parent
6f9a9071
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
3 deletions
+9
-3
Doc/extending/embedding.rst
Doc/extending/embedding.rst
+8
-2
Doc/extending/extending.rst
Doc/extending/extending.rst
+1
-1
No files found.
Doc/extending/embedding.rst
View file @
483d6c50
...
...
@@ -223,11 +223,17 @@ Python extension. For example::
NULL, NULL, NULL, NULL
};
static PyObject*
PyInit_emb(void)
{
return PyModule_Create(&EmbModule);
}
Insert the above code just above the :cfunc:`main` function. Also, insert the
following two statements
directly after
:cfunc:`Py_Initialize`::
following two statements
before the call to
:cfunc:`Py_Initialize`::
numargs = argc;
Py
Module_Create(&EmbModule
);
Py
Import_AppendInittab("emb", &PyInit_emb
);
These two lines initialize the ``numargs`` variable, and make the
:func:`emb.numargs` function accessible to the embedded Python interpreter.
...
...
Doc/extending/extending.rst
View file @
483d6c50
...
...
@@ -342,7 +342,7 @@ satisfactorily. The init function must return the module object to its caller,
so that it then gets inserted into ``sys.modules``.
When embedding Python, the :cfunc:`PyInit_spam` function is not called
automatically unless there's an entry in the :cdata:`
_
PyImport_Inittab` table.
automatically unless there's an entry in the :cdata:`PyImport_Inittab` table.
To add the module to the initialization table, use :cfunc:`PyImport_AppendInittab`,
optionally followed by an import of the module::
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment