8000 Port BPO-37025 (GH python/cpython#16897) · BCSharp/ironclad@f3bde76 · GitHub
[go: up one dir, main page]

Skip to content

Commit f3bde76

Browse files
committed
Port BPO-37025 (GH python/cpython#16897)
1 parent cba514c commit f3bde76

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

stub/ic_msvcr90.c

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ int IC_fclose(FILE *file)
3737
}
3838

3939
// and this lot is copied (with tiny changes) from PC/nt_dl.c, to enable exactly what the following comment describes
40+
// In CPython 3.5 it has been conditionally disabled
41+
// and removed completely in 3.9 (https://github.com/python/cpython/issues/83734)
4042

4143
#include <Windows.h>
4244

@@ -51,12 +53,14 @@ int IC_fclose(FILE *file)
5153
// As an added complication, this magic only works on XP or later - we simply
5254
// use the existence (or not) of the relevant function pointers from kernel32.
5355
// See bug 4566 (http://python.org/sf/4566) for more details.
56+
// In Visual Studio 2010, side by side assemblies are no longer used by
57+
// default.
5458

5559
typedef BOOL (WINAPI * PFN_GETCURRENTACTCTX)(HANDLE *);
5660
typedef BOOL (WINAPI * PFN_ACTIVATEACTCTX)(HANDLE, ULONG_PTR *);
5761
typedef BOOL (WINAPI * PFN_DEACTIVATEACTCTX)(DWORD, ULONG_PTR);
58-
typedef BOOL (WINAPI * PFN_ADDREFACTCTX)(HANDLE);
59-
typedef BOOL (WINAPI * PFN_RELEASEACTCTX)(HANDLE);
62+
typedef void (WINAPI * PFN_ADDREFACTCTX)(HANDLE);
63+
typedef void (WINAPI * PFN_RELEASEACTCTX)(HANDLE);
6064

6165
// locals and function pointers for this activation context magic.
6266
static HANDLE PyWin_DLLhActivationContext = NULL; // one day it might be public
@@ -108,9 +112,13 @@ BOOL WINAPI DllMain (HINSTANCE hInst,
108112
// capture our activation context for use when loading extensions.
109113
_LoadActCtxPointers();
110114
if (pfnGetCurrentActCtx && pfnAddRefActCtx)
111-
if ((*pfnGetCurrentActCtx)(&PyWin_DLLhActivationContext))
112-
if (!(*pfnAddRefActCtx)(PyWin_DLLhActivationContext))
113-
printf("Python failed to load the default activation context\n");
115+
if ((*pfnGetCurrentActCtx)(&PyWin_DLLhActivationContext)) {
116+
(*pfnAddRefActCtx)(PyWin_DLLhActivationContext);
117+
}
118+
else {
119+
printf("Python failed to load the default activation context\n");
120+
return FALSE;
121+
}
114122
break;
115123

116124
case DLL_PROCESS_DETACH:

0 commit comments

Comments
 (0)
0