@@ -120,7 +120,7 @@ static void setup_cysignals_handlers(void);
120120static void cysigs_interrupt_handler (int sig );
121121static void cysigs_signal_handler (int sig );
122122
123- static void do_raise_exception (int sig );
123+ static void _do_raise_exception (int sig );
124124static void sigdie (int sig , const char * s );
125125
126126#define BACKTRACELEN 1024
@@ -392,11 +392,10 @@ static void cysigs_interrupt_handler(int sig)
392392 {
393393 if (!cysigs .block_sigint && !custom_signal_is_blocked ())
394394 {
395- /* Raise an exception so Python can see it */
396- do_raise_exception ( sig );
397-
395+ /* Jump back to sig_on() (the first one if there is a stack).
396+ * The signal number is encoded in the return value of sigsetjmp.
397+ * Do NOT call Python code from signal handler! */
398398#if !_WIN32
399- /* Jump back to sig_on() (the first one if there is a stack) */
400399 siglongjmp (trampoline , sig );
401400#endif
402401 }
@@ -449,10 +448,10 @@ static void cysigs_signal_handler(int sig)
449448 }
450449#endif
451450
452- /* Raise an exception so Python can see it */
453- do_raise_exception (sig );
451+ /* Jump back to sig_on() (the first one if there is a stack).
452+ * The signal number is encoded in the return value of sigsetjmp.
453+ * Do NOT call Python code from signal handler! */
454454 #if !_WIN32
455- /* Jump back to sig_on() (the first one if there is a stack) */
456455 siglongjmp (trampoline , sig );
457456 #endif
458457 }
@@ -554,15 +553,15 @@ static void setup_trampoline(void)
554553
555554
556555/* This calls sig_raise_exception() to actually raise the exception. */
557- static void do_raise_exception (int sig )
556+ static void _do_raise_exception (int sig )
558557{
559558#if ENABLE_DEBUG_CYSIGNALS
560559 struct timespec raisetime ;
561560 if (cysigs .debug_level >= 2 ) {
562561 get_monotonic_time (& raisetime );
563562 long delta_ms = (raisetime .tv_sec - sigtime .tv_sec )* 1000L + (raisetime .tv_nsec - sigtime .tv_nsec )/1000000L ;
564563 PyGILState_STATE gilstate = PyGILState_Ensure ();
565- print_stderr ("do_raise_exception (sig=" );
564+ print_stderr ("_do_raise_exception (sig=" );
566565 print_stderr_long (sig );
567566 print_stderr (")\nPyErr_Occurred() = " );
568567 print_stderr_ptr (PyErr_Occurred ());
@@ -588,7 +587,7 @@ static void _sig_on_interrupt_received(void)
588587 sigprocmask (SIG_BLOCK , & sigmask_with_sigint , & oldset );
589588#endif
590589
591- do_raise_exception (cysigs .interrupt_received );
590+ _do_raise_exception (cysigs .interrupt_received );
592591 cysigs .sig_on_count = 0 ;
593592 cysigs .interrupt_received = 0 ;
594593 custom_set_pending_signal (0 );
0 commit comments