mirror of
https://github.com/python/cpython.git
synced 2025-07-24 03:35:53 +00:00
Issue #5319: New Py_FinalizeEx() API to exit with status 120 on failure
This commit is contained in:
parent
92d5fbaf8f
commit
b4ce1fc31b
18 changed files with 120 additions and 58 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue