summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZackery Spytz <zspytz@gmail.com>2019-10-23 18:15:55 (GMT)
committerSteve Dower <steve.dower@python.org>2019-10-23 18:15:55 (GMT)
commit009a6928727b23344613ab6a9a52b9da56ab905c (patch)
treecc7134298e1ba3e3f01ce0649551b1dfd6fe14ce
parent9978a9553b5273ca8f55c4130383c4ee151fbe2a (diff)
downloadcpython-009a6928727b23344613ab6a9a52b9da56ab905c.zip
cpython-009a6928727b23344613ab6a9a52b9da56ab905c.tar.gz
cpython-009a6928727b23344613ab6a9a52b9da56ab905c.tar.bz2
bpo-37025: AddRefActCtx() shouldn't be checked for failure (GH-16897)
AddRefActCtx() does not return a value.
-rw-r--r--Misc/NEWS.d/next/Windows/2019-10-04-03-46-36.bpo-37025.tLheEe.rst2
-rw-r--r--PC/dl_nt.c15
2 files changed, 12 insertions, 5 deletions
diff --git a/Misc/NEWS.d/next/Windows/2019-10-04-03-46-36.bpo-37025.tLheEe.rst b/Misc/NEWS.d/next/Windows/2019-10-04-03-46-36.bpo-37025.tLheEe.rst
new file mode 100644
index 0000000..7c0f9dc
--- /dev/null
+++ b/Misc/NEWS.d/next/Windows/2019-10-04-03-46-36.bpo-37025.tLheEe.rst
@@ -0,0 +1,2 @@
+``AddRefActCtx()`` was needlessly being checked for failure in
+``PC/dl_nt.c``.
diff --git a/PC/dl_nt.c b/PC/dl_nt.c
index ef1ce09..3e58bac 100644
--- a/PC/dl_nt.c
+++ b/PC/dl_nt.c
@@ -33,8 +33,8 @@ const char *PyWin_DLLVersionString = dllVersionBuffer;
typedef BOOL (WINAPI * PFN_GETCURRENTACTCTX)(HANDLE *);
typedef BOOL (WINAPI * PFN_ACTIVATEACTCTX)(HANDLE, ULONG_PTR *);
typedef BOOL (WINAPI * PFN_DEACTIVATEACTCTX)(DWORD, ULONG_PTR);
-typedef BOOL (WINAPI * PFN_ADDREFACTCTX)(HANDLE);
-typedef BOOL (WINAPI * PFN_RELEASEACTCTX)(HANDLE);
+typedef void (WINAPI * PFN_ADDREFACTCTX)(HANDLE);
+typedef void (WINAPI * PFN_RELEASEACTCTX)(HANDLE);
// locals and function pointers for this activation context magic.
static HANDLE PyWin_DLLhActivationContext = NULL; // one day it might be public
@@ -90,9 +90,14 @@ BOOL WINAPI DllMain (HANDLE hInst,
// and capture our activation context for use when loading extensions.
_LoadActCtxPointers();
if (pfnGetCurrentActCtx && pfnAddRefActCtx)
- if ((*pfnGetCurrentActCtx)(&PyWin_DLLhActivationContext))
- if (!(*pfnAddRefActCtx)(PyWin_DLLhActivationContext))
- OutputDebugString("Python failed to load the default activation context\n");
+ if ((*pfnGetCurrentActCtx)(&PyWin_DLLhActivationContext)) {
+ (*pfnAddRefActCtx)(PyWin_DLLhActivationContext);
+ }
+ else {
+ OutputDebugString("Python failed to load the default "
+ "activation context\n");
+ return FALSE;
+ }
break;
case DLL_PROCESS_DETACH: