summaryrefslogtreecommitdiff
path: root/Doc/extending/embedding.rst
diff options
context:
space:
mode:
authorSteve Dower <steve.dower@microsoft.com>2017-02-04 15:39:38 -0800
committerSteve Dower <steve.dower@microsoft.com>2017-02-04 15:39:38 -0800
commit1a5780aabb550cae175ad8711e2f33ba644d0ddb (patch)
tree68e47eaafb4ccc17bbdb7668c6058984945b332d /Doc/extending/embedding.rst
parent956c7cfa7111ab5458e2f69868a05b7b84fc6843 (diff)
parentd1d8706cdb77e2adbbb4110338dcda0e1811f892 (diff)
downloadcpython-1a5780aabb550cae175ad8711e2f33ba644d0ddb.tar.gz
Issue #29319: Prevent RunMainFromImporter overwriting sys.path[0].
Diffstat (limited to 'Doc/extending/embedding.rst')
-rw-r--r--Doc/extending/embedding.rst6
1 files changed, 4 insertions, 2 deletions
diff --git a/Doc/extending/embedding.rst b/Doc/extending/embedding.rst
index 64033dcd97..ab2f61614a 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