aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Python/dynload_win.c
diff options
context:
space:
mode:
Diffstat (limited to 'Python/dynload_win.c')
-rw-r--r--Python/dynload_win.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/Python/dynload_win.c b/Python/dynload_win.c
index 7bd04d573df..acab05e2c6d 100644
--- a/Python/dynload_win.c
+++ b/Python/dynload_win.c
@@ -163,6 +163,7 @@ static char *GetPythonImport (HINSTANCE hModule)
return NULL;
}
+#ifdef Py_ENABLE_SHARED
/* Load python3.dll before loading any extension module that might refer
to it. That way, we can be sure that always the python3.dll corresponding
to this python DLL is loaded, not a python3.dll that might be on the path
@@ -216,6 +217,7 @@ _Py_CheckPython3(void)
return hPython3 != NULL;
#undef MAXPATHLEN
}
+#endif /* Py_ENABLE_SHARED */
dl_funcptr _PyImport_FindSharedFuncptrWindows(const char *prefix,
const char *shortname,
@@ -224,7 +226,9 @@ dl_funcptr _PyImport_FindSharedFuncptrWindows(const char *prefix,
dl_funcptr p;
char funcname[258], *import_python;
+#ifdef Py_ENABLE_SHARED
_Py_CheckPython3();
+#endif /* Py_ENABLE_SHARED */
wchar_t *wpathname = PyUnicode_AsWideCharString(pathname, NULL);
if (wpathname == NULL)
@@ -234,10 +238,12 @@ dl_funcptr _PyImport_FindSharedFuncptrWindows(const char *prefix,
{
HINSTANCE hDLL = NULL;
+#ifdef MS_WINDOWS_DESKTOP
unsigned int old_mode;
/* Don't display a message box when Python can't load a DLL */
old_mode = SetErrorMode(SEM_FAILCRITICALERRORS);
+#endif
/* bpo-36085: We use LoadLibraryEx with restricted search paths
to avoid DLL preloading attacks and enable use of the
@@ -250,8 +256,10 @@ dl_funcptr _PyImport_FindSharedFuncptrWindows(const char *prefix,
Py_END_ALLOW_THREADS
PyMem_Free(wpathname);
+#ifdef MS_WINDOWS_DESKTOP
/* restore old error mode settings */
SetErrorMode(old_mode);
+#endif
if (hDLL==NULL){
PyObject *message;