This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author idadesub
Recipients erickt, georg.brandl, idadesub
Date 2008-08-28.21:27:23
SpamBayes Score 4.65572e-13
Marked as misclassified No
Message-id <1ef034530808281427t5e979bf8p29d9b35ee936a49a@mail.gmail.com>
In-reply-to <1219956531.21.0.0850096773002.issue3717@psf.upfronthosting.co.za>
Content
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 */
-	initxyzzy();
+	PyInit_xyzzy();

 	/* Define sys.argv.  It is up to the application if you
 	   want this; you can also let it undefined (since the Python
@@ -26,10 +26,10 @@

 	/* Execute some Python statements (in module __main__) */
 	PyRun_SimpleString("import sys\n");
-	PyRun_SimpleString("print sys.builtin_module_names\n");
-	PyRun_SimpleString("print sys.modules.keys()\n");
-	PyRun_SimpleString("print sys.executable\n");
-	PyRun_SimpleString("print sys.argv\n");
+	PyRun_SimpleString("print(sys.builtin_module_names)\n");
+	PyRun_SimpleString("print(sys.modules.keys())\n");
+	PyRun_SimpleString("print(sys.executable)\n");
+	PyRun_SimpleString("print(sys.argv)\n");

 	/* Note that you can call any public function of the Python
 	   interpreter here, e.g. call_object(). */
@@ -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
History
Date User Action Args
2008-08-28 21:27:25idadesubsetrecipients: + idadesub, georg.brandl, erickt
2008-08-28 21:27:24idadesublinkissue3717 messages
2008-08-28 21:27:23idadesubcreate