diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2014-08-01 10:28:49 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2014-08-01 10:28:49 (GMT) |
commit | 25e014bd91e2f64b3231ef2bf5ddac8bb99ed637 (patch) | |
tree | 117d491c5ed3f749eadee5a6e457371acac81318 /Doc/extending/extending.rst | |
parent | f6a271ae980d2f3fb450f745b8f87624378156c4 (diff) | |
download | cpython-25e014bd91e2f64b3231ef2bf5ddac8bb99ed637.zip cpython-25e014bd91e2f64b3231ef2bf5ddac8bb99ed637.tar.gz cpython-25e014bd91e2f64b3231ef2bf5ddac8bb99ed637.tar.bz2 |
Issue #18395, #22108: Update embedded Python examples to decode correctly
command line parameters: use Py_DecodeLocale() and PyUnicode_DecodeFSDefault().
Diffstat (limited to 'Doc/extending/extending.rst')
-rw-r--r-- | Doc/extending/extending.rst | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/Doc/extending/extending.rst b/Doc/extending/extending.rst index a3bf265..ecce38b 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 |