summaryrefslogtreecommitdiff
path: root/PC/bdist_wininst/install.c
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 /PC/bdist_wininst/install.c
parent956c7cfa7111ab5458e2f69868a05b7b84fc6843 (diff)
parentd1d8706cdb77e2adbbb4110338dcda0e1811f892 (diff)
downloadcpython-1a5780aabb550cae175ad8711e2f33ba644d0ddb.tar.gz
Issue #29319: Prevent RunMainFromImporter overwriting sys.path[0].
Diffstat (limited to 'PC/bdist_wininst/install.c')
-rw-r--r--PC/bdist_wininst/install.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/PC/bdist_wininst/install.c b/PC/bdist_wininst/install.c
index adbb7334f0..17cc30d25c 100644
--- a/PC/bdist_wininst/install.c
+++ b/PC/bdist_wininst/install.c
@@ -718,7 +718,7 @@ static int prepare_script_environment(HINSTANCE hPython)
* 1 if the Python-dll does not export the functions we need
* 2 if no install-script is specified in pathname
* 3 if the install-script file could not be opened
- * the return value of PyRun_SimpleString() otherwise,
+ * the return value of PyRun_SimpleString() or Py_FinalizeEx() otherwise,
* which is 0 if everything is ok, -1 if an exception had occurred
* in the install-script.
*/
@@ -731,7 +731,7 @@ do_run_installscript(HINSTANCE hPython, char *pathname, int argc, char **argv)
DECLPROC(hPython, void, Py_Initialize, (void));
DECLPROC(hPython, int, PySys_SetArgv, (int, wchar_t **));
DECLPROC(hPython, int, PyRun_SimpleString, (char *));
- DECLPROC(hPython, void, Py_Finalize, (void));
+ DECLPROC(hPython, int, Py_FinalizeEx, (void));
DECLPROC(hPython, PyObject *, Py_BuildValue, (char *, ...));
DECLPROC(hPython, PyObject *, PyCFunction_New,
(PyMethodDef *, PyObject *));
@@ -739,7 +739,7 @@ do_run_installscript(HINSTANCE hPython, char *pathname, int argc, char **argv)
DECLPROC(hPython, PyObject *, PyErr_Format, (PyObject *, char *));
if (!Py_Initialize || !PySys_SetArgv
- || !PyRun_SimpleString || !Py_Finalize)
+ || !PyRun_SimpleString || !Py_FinalizeEx)
return 1;
if (!Py_BuildValue || !PyArg_ParseTuple || !PyErr_Format)
@@ -786,7 +786,9 @@ do_run_installscript(HINSTANCE hPython, char *pathname, int argc, char **argv)
}
}
}
- Py_Finalize();
+ if (Py_FinalizeEx() < 0) {
+ result = -1;
+ }
close(fh);
return result;
@@ -848,11 +850,11 @@ static int do_run_simple_script(HINSTANCE hPython, char *script)
int rc;
DECLPROC(hPython, void, Py_Initialize, (void));
DECLPROC(hPython, void, Py_SetProgramName, (wchar_t *));
- DECLPROC(hPython, void, Py_Finalize, (void));
+ DECLPROC(hPython, int, Py_FinalizeEx, (void));
DECLPROC(hPython, int, PyRun_SimpleString, (char *));
DECLPROC(hPython, void, PyErr_Print, (void));
- if (!Py_Initialize || !Py_SetProgramName || !Py_Finalize ||
+ if (!Py_Initialize || !Py_SetProgramName || !Py_FinalizeEx ||
!PyRun_SimpleString || !PyErr_Print)
return -1;
@@ -862,7 +864,9 @@ static int do_run_simple_script(HINSTANCE hPython, char *script)
rc = PyRun_SimpleString(script);
if (rc)
PyErr_Print();
- Py_Finalize();
+ if (Py_FinalizeEx() < 0) {
+ rc = -1;
+ }
return rc;
}