mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
gh-102255: Improve build support for Windows API partitions (GH-102256)
Add `MS_WINDOWS_DESKTOP`, `MS_WINDOWS_APPS`, `MS_WINDOWS_SYSTEM` and `MS_WINDOWS_GAMES` preprocessor definitions to allow switching off functionality missing from particular API partitions ("partitions" are used in Windows to identify overlapping subsets of APIs). CPython only officially supports `MS_WINDOWS_DESKTOP` and `MS_WINDOWS_SYSTEM` (APPS is included by normal desktop builds, but APPS without DESKTOP is not covered). Other configurations are a convenience for people building their own runtimes. `MS_WINDOWS_GAMES` is for the Xbox subset of the Windows API, which is also available on client OS, but is restricted compared to `MS_WINDOWS_DESKTOP`. These restrictions may change over time, as they relate to the build headers rather than the OS support, and so we assume that Xbox builds will use the latest available version of the GDK.
This commit is contained in:
parent
ca066bdbed
commit
c6858d1e7f
36 changed files with 633 additions and 100 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue