-
-
Notifications
You must be signed in to change notification settings - Fork 30k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Py_InitModule* is still referenced in docs #47967
Comments
The docs still reference Py_InitModule*, which was removed in r64107. |
On Thu, Aug 28, 2008 at 1:48 PM, Erick Tryzelaar <report@bugs.python.org> wrote:
Here's a patch to get demo.c working, though it's acting a little Index: Demo/embed/demo.c #include "Python.h" -void initxyzzy(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();
/* 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");
@@ -57,9 +57,22 @@ -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 #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 |
In your patch, it is not correct to declare main as You have to perform the conversion yourself. Look for example at The problem with importexc.c is more serious; I've filled bpo-3723 for |
Here is a patch that makes Demo/embed compile and run successfully. |
Looks good to me. |
Committed as r66961. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: