Files
Serhiy Storchaka 159a3604b9 [3.13] gh-157672: Keep Python's signal handlers when Tk is initialized on macOS (GH-157673) (GH-157989)
Tk on macOS replaces the SIGINT, SIGHUP and SIGTERM handlers with its
own, which exits the process, so Ctrl-C terminated a tkinter program
instead of raising KeyboardInterrupt.  Save the handlers installed by
Python before Tk_Init() and restore them after it.

This affects Tk 8.6.11 to 8.6.18 and 9.0 to 9.0.4.  Tk itself is fixed
in 8.6.19 and 9.0.5.

(cherry picked from commit 4532b36db5)

On 3.13 there was no Tkinter_TkInit(), and tkappinit.c, which is used
when Python is built with WITH_APPINIT (as on macOS), called Tk_Init()
directly, bypassing the fix.
2026-09-23 11:40:46 +00:00

22 lines
630 B
C

#ifndef TKINTER_H
#define TKINTER_H
/* This header is used to share some macros between _tkinter.c and
* tkappinit.c.
* Be sure to include tk.h before including this header so
* TK_HEX_VERSION is properly defined. */
/* TK_RELEASE_LEVEL is always one of the following:
* TCL_ALPHA_RELEASE 0
* TCL_BETA_RELEASE 1
* TCL_FINAL_RELEASE 2
*/
#define TK_HEX_VERSION ((TK_MAJOR_VERSION << 24) | \
(TK_MINOR_VERSION << 16) | \
(TK_RELEASE_LEVEL << 8) | \
(TK_RELEASE_SERIAL << 0))
int Tkinter_TkInit(Tcl_Interp *interp);
#endif /* !TKINTER_H */