Issue 3717: Py_InitModule* is still referenced in docs (original) (raw)

On Thu, Aug 28, 2008 at 1:48 PM, Erick Tryzelaar <report@bugs.python.org> wrote:

New submission from Erick Tryzelaar <idadesub@users.sourceforge.net>:

The docs still reference Py_InitModule*, which was removed in r64107. Also, Demo/embed/demo.c still use Py_InitModule, and thus doesn't compile.

Here's a patch to get demo.c working, though it's acting a little strange. Printing out sys.argv results in japanese characters for some reason.

Index: Demo/embed/demo.c

--- Demo/embed/demo.c (revision 66055) +++ Demo/embed/demo.c (working copy) @@ -2,9 +2,9 @@

#include "Python.h"

-void initxyzzy(void); /* Forward / +PyObject PyInit_xyzzy(void); /* Forward */

-main(int argc, char **argv) +main(int argc, wchar_t *argv) { / Pass argv[0] to the Python interpreter */ Py_SetProgramName(argv[0]); @@ -13,7 +13,7 @@ Py_Initialize();

 /* Add a static module */

@@ -26,10 +26,10 @@

 /* Execute some Python statements (in module __main__) */
 PyRun_SimpleString("import sys\n");

@@ -57,9 +57,22 @@ {NULL, NULL} /* sentinel */ };

-void -initxyzzy(void) +static struct PyModuleDef xyzzymodule = { + {}, /* m_base / + "xyzzy", / m_name / + 0, / m_doc / + 0, / m_size / + xyzzy_methods, / m_methods / + 0, / m_reload / + 0, / m_traverse / + 0, / m_clear / + 0, / m_free / +}; + +PyObject +PyInit_xyzzy(void) { - PyImport_AddModule("xyzzy"); - Py_InitModule("xyzzy", xyzzy_methods); + PyObject* res = PyModule_Create(&xyzzymodule); + if (!res) return NULL; + return res; }

With loop.c, there are issues with char*/wchar_t* and I'm not sure what the right approach is. Finally, importexc.c is segfaulting with:

#0 0x0005b2f3 in PyDict_SetItem (op=0x0, key=0x44bed0, value=0x17d460) at Objects/dictobject.c:712 #1 0x0005ee02 in PyDict_SetItemString (v=0x0, key=0x16e860 "last_type", item=0x17d460) at Objects/dictobject.c:2090 #2 0x0012c23a in PySys_SetObject (name=0x16e860 "last_type", v=0x17d460) at Python/sysmodule.c:67 #3 0x00122c99 in PyErr_PrintEx (set_sys_last_vars=1) at Python/pythonrun.c:1254 #4 0x001228bc in PyErr_Print () at Python/pythonrun.c:1150 #5 0x001223a1 in PyRun_SimpleStringFlags (command=0x157b80 "import sys", flags=0x0) at Python/pythonrun.c:1075 #6 0x0000243b in main () at importexc.c:13