Skip to content

Commit 009a692

Browse files
ZackerySpytzzooba
authored andcommitted
bpo-37025: AddRefActCtx() shouldn't be checked for failure (pythonGH-16897)
AddRefActCtx() does not return a value.
1 parent 9978a95 commit 009a692

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
``AddRefActCtx()`` was needlessly being checked for failure in
2+
``PC/dl_nt.c``.

PC/dl_nt.c

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ const char *PyWin_DLLVersionString = dllVersionBuffer;
3333
typedef BOOL (WINAPI * PFN_GETCURRENTACTCTX)(HANDLE *);
3434
typedef BOOL (WINAPI * PFN_ACTIVATEACTCTX)(HANDLE, ULONG_PTR *);
3535
typedef BOOL (WINAPI * PFN_DEACTIVATEACTCTX)(DWORD, ULONG_PTR);
36-
typedef BOOL (WINAPI * PFN_ADDREFACTCTX)(HANDLE);
37-
typedef BOOL (WINAPI * PFN_RELEASEACTCTX)(HANDLE);
36+
typedef void (WINAPI * PFN_ADDREFACTCTX)(HANDLE);
37+
typedef void (WINAPI * PFN_RELEASEACTCTX)(HANDLE);
3838

3939
// locals and function pointers for this activation context magic.
4040
static HANDLE PyWin_DLLhActivationContext = NULL; // one day it might be public
@@ -90,9 +90,14 @@ BOOL WINAPI DllMain (HANDLE hInst,
9090
// and capture our activation context for use when loading extensions.
9191
_LoadActCtxPointers();
9292
if (pfnGetCurrentActCtx && pfnAddRefActCtx)
93-
if ((*pfnGetCurrentActCtx)(&PyWin_DLLhActivationContext))
94-
if (!(*pfnAddRefActCtx)(PyWin_DLLhActivationContext))
95-
OutputDebugString("Python failed to load the default activation context\n");
93+
if ((*pfnGetCurrentActCtx)(&PyWin_DLLhActivationContext)) {
94+
(*pfnAddRefActCtx)(PyWin_DLLhActivationContext);
95+
}
96+
else {
97+
OutputDebugString("Python failed to load the default "
98+
"activation context\n");
99+
return FALSE;
100+
}
96101
break;
97102

98103
case DLL_PROCESS_DETACH:

0 commit comments

Comments
 (0)