diff options
author | Martin Panter <vadmium+py@gmail.com> | 2015-11-30 03:18:29 (GMT) |
---|---|---|
committer | Martin Panter <vadmium+py@gmail.com> | 2015-11-30 03:18:29 (GMT) |
commit | b4ce1fc31be5614d527d77c55018281ebbcd70ab (patch) | |
tree | 8f51eb2efd5191ae1284be5d82b5d84f4bf6a424 /Doc/extending | |
parent | 92d5fbaf8f6c3c3c8ab0c83be848fcc206f02b22 (diff) | |
download | cpython-b4ce1fc31be5614d527d77c55018281ebbcd70ab.zip cpython-b4ce1fc31be5614d527d77c55018281ebbcd70ab.tar.gz cpython-b4ce1fc31be5614d527d77c55018281ebbcd70ab.tar.bz2 |
Issue #5319: New Py_FinalizeEx() API to exit with status 120 on failure
Diffstat (limited to 'Doc/extending')
-rw-r--r-- | Doc/extending/embedding.rst | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/Doc/extending/embedding.rst b/Doc/extending/embedding.rst index acd60ae..1546b1a 100644 --- a/Doc/extending/embedding.rst +++ b/Doc/extending/embedding.rst @@ -67,7 +67,9 @@ perform some operation on a file. :: Py_Initialize(); PyRun_SimpleString("from time import time,ctime\n" "print('Today is', ctime(time()))\n"); - Py_Finalize(); + if (Py_FinalizeEx() < 0) { + exit(120); + } PyMem_RawFree(program); return 0; } @@ -76,7 +78,7 @@ The :c:func:`Py_SetProgramName` function should be called before :c:func:`Py_Initialize` to inform the interpreter about paths to Python run-time libraries. Next, the Python interpreter is initialized with :c:func:`Py_Initialize`, followed by the execution of a hard-coded Python script -that prints the date and time. Afterwards, the :c:func:`Py_Finalize` call shuts +that prints the date and time. Afterwards, the :c:func:`Py_FinalizeEx` call shuts the interpreter down, followed by the end of the program. In a real program, you may want to get the Python script from another source, perhaps a text-editor routine, a file, or a database. Getting the Python code from a file can better |