summaryrefslogtreecommitdiff
path: root/Doc/extending/extending.rst
diff options
context:
space:
mode:
Diffstat (limited to 'Doc/extending/extending.rst')
-rw-r--r--Doc/extending/extending.rst12
1 files changed, 11 insertions, 1 deletions
diff --git a/Doc/extending/extending.rst b/Doc/extending/extending.rst
index e78fe0c4b1..12868d3f74 100644
--- a/Doc/extending/extending.rst
+++ b/Doc/extending/extending.rst
@@ -370,11 +370,17 @@ optionally followed by an import of the module::
int
main(int argc, char *argv[])
{
+ wchar_t *program = Py_DecodeLocale(argv[0], NULL);
+ if (program == NULL) {
+ fprintf(stderr, "Fatal error: cannot decode argv[0]\n");
+ exit(1);
+ }
+
/* Add a built-in module, before Py_Initialize */
PyImport_AppendInittab("spam", PyInit_spam);
/* Pass argv[0] to the Python interpreter */
- Py_SetProgramName(argv[0]);
+ Py_SetProgramName(program);
/* Initialize the Python interpreter. Required. */
Py_Initialize();
@@ -386,6 +392,10 @@ optionally followed by an import of the module::
...
+ PyMem_RawFree(program);
+ return 0;
+ }
+
.. note::
Removing entries from ``sys.modules`` or importing compiled modules into