Skip to content

Commit aa881c4

Browse files
committed
Unset the Python DLL handler after finalization
1 parent 1305aac commit aa881c4

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

ahkpy/Lib/PythonDll.ahk

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,9 @@ LoadLibraryEx(libFileName, flags:=0) {
5353
}
5454

5555
PythonDllCall(function, args*) {
56-
return DllCall(CachedProcAddress(function), args*)
56+
if (HPYTHON_DLL) {
57+
return DllCall(CachedProcAddress(function), args*)
58+
}
5759
}
5860

5961
CachedProcAddress(symbol, returnType:="Ptr") {
@@ -81,9 +83,7 @@ Py_BuildValue(format) {
8183

8284
Py_FinalizeEx() {
8385
; int Py_FinalizeEx()
84-
if (HPYTHON_DLL) {
85-
return PythonDllCall("Py_FinalizeEx", "Cdecl Int")
86-
}
86+
return PythonDllCall("Py_FinalizeEx", "Cdecl Int")
8787
}
8888

8989
Py_IncRef(pyObject) {

ahkpy/Python.ahk

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -648,7 +648,9 @@ HandleExit(reason, code, label:="OnExit") {
648648
}
649649
}
650650

651-
if (Py_FinalizeEx() < 0) {
651+
err := Py_FinalizeEx()
652+
HPYTHON_DLL := NULL
653+
if (err) {
652654
code := 120
653655
ExitApp, %code%
654656
}

0 commit comments

Comments
 (0)