@@ -37,6 +37,8 @@ int IC_fclose(FILE *file)
37
37
}
38
38
39
39
// 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)
40
42
41
43
#include <Windows.h>
42
44
@@ -51,12 +53,14 @@ int IC_fclose(FILE *file)
51
53
// As an added complication, this magic only works on XP or later - we simply
52
54
// use the existence (or not) of the relevant function pointers from kernel32.
53
55
// 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.
54
58
55
59
typedef BOOL (WINAPI * PFN_GETCURRENTACTCTX )(HANDLE * );
56
60
typedef BOOL (WINAPI * PFN_ACTIVATEACTCTX )(HANDLE , ULONG_PTR * );
57
61
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 );
60
64
61
65
// locals and function pointers for this activation context magic.
62
66
static HANDLE PyWin_DLLhActivationContext = NULL ; // one day it might be public
@@ -108,9 +112,13 @@ BOOL WINAPI DllMain (HINSTANCE hInst,
108
112
// capture our activation context for use when loading extensions.
109
113
_LoadActCtxPointers ();
110
114
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
+ }
114
122
break ;
115
123
116
124
case DLL_PROCESS_DETACH :
0 commit comments