Skip to content

Commit 4ea577a

Browse files
committed
fix(py): overwrite Nim's SIGINT handler when not defined pylibUseNimIntHandler
1 parent af83c62 commit 4ea577a

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/pylib/Lib/signal_impl/signals.nim

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,12 @@ proc signal_get_set_handlers(state: signal_state_t) =
8686
set_handler(signum, fn)
8787

8888
# Install Python SIGINT handler which raises KeyboardInterrupt
89-
let sigint_func = get_handler(SIGINT)
90-
if sigint_func == state.default_handler:
89+
90+
template installIntHandler(sigint_func): bool{.dirty.} =
91+
when not defined(pylibUseNimIntHandler): true
92+
else: get_handler(SIGINT) == state.default_handler
93+
94+
if installIntHandler(sigint_func):
9195
let int_handler = default_int_handler
9296
set_handler(SIGINT, int_handler)
9397
discard PyOS_setsig(SIGINT, signal_handler)

0 commit comments

Comments
 (0)