From b4ce1fc31be5614d527d77c55018281ebbcd70ab Mon Sep 17 00:00:00 2001 From: Martin Panter Date: Mon, 30 Nov 2015 03:18:29 +0000 Subject: Issue #5319: New Py_FinalizeEx() API to exit with status 120 on failure --- Doc/extending/embedding.rst | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'Doc/extending') diff --git a/Doc/extending/embedding.rst b/Doc/extending/embedding.rst index acd60aef8c..1546b1adcf 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 -- cgit v1.2.1