File tree Expand file tree Collapse file tree 1 file changed +19
-14
lines changed Expand file tree Collapse file tree 1 file changed +19
-14
lines changed Original file line number Diff line number Diff line change @@ -269,19 +269,21 @@ HandleCtrlEvent(signal) {
269
269
270
270
CheckSignals () {
271
271
gstate := PyGILState_Ensure()
272
- err := PyErr_CheckSignals()
273
- if (err == 0 ) {
274
- PyGILState_Release(gstate)
275
- return
276
- }
277
- ; Python's signal handler raised an exception.
278
- PyExc_KeyboardInterrupt := CachedProcAddress(" PyExc_KeyboardInterrupt" , " PtrP" )
279
- if (PyErr_ExceptionMatches(PyExc_KeyboardInterrupt)) {
272
+ try {
273
+ err := PyErr_CheckSignals()
274
+ if (err == 0 ) {
275
+ return
276
+ }
277
+ ; Python's signal handler raised an exception.
278
+ PyExc_KeyboardInterrupt := CachedProcAddress(" PyExc_KeyboardInterrupt" , " PtrP" )
279
+ if (PyErr_ExceptionMatches(PyExc_KeyboardInterrupt)) {
280
+ PyErr_Print()
281
+ ExitApp , %STATUS_CONTROL_C_EXIT%
282
+ }
280
283
PyErr_Print()
281
- ExitApp , %STATUS_CONTROL_C_EXIT%
284
+ } finally {
285
+ PyGILState_Release(gstate)
282
286
}
283
- PyErr_Print()
284
- PyGILState_Release(gstate)
285
287
}
286
288
287
289
AHKCall (self, args ) {
@@ -432,9 +434,12 @@ class WrappedPythonCallable {
432
434
__Delete () {
433
435
WRAPPED_PYTHON_CALLABLE.Delete (this.pyFunc)
434
436
gstate := PyGILState_Ensure()
435
- Py_DecRef(this.pyFunc)
436
- Py_DecRef(this.ctx)
437
- PyGILState_Release(gstate)
437
+ try {
438
+ Py_DecRef(this.pyFunc)
439
+ Py_DecRef(this.ctx)
440
+ } finally {
441
+ PyGILState_Release(gstate)
442
+ }
438
443
}
439
444
}
440
445
You can’t perform that action at this time.
0 commit comments