Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Put event_tstate into module state
  • Loading branch information
erlend-aasland committed Mar 29, 2023
commit 686b69a1dce6d100a12a95d6db59b384d92bc5b1
9 changes: 4 additions & 5 deletions Modules/_tkinter.c
Original file line number Diff line number Diff line change
Expand Up @@ -3200,16 +3200,14 @@ MyFileProc(void *clientData, int mask)
}
#endif

static PyThreadState *event_tstate = NULL;

static int
EventHook(void)
{
module_state *st = GLOBAL_STATE();
#ifndef MS_WINDOWS
int tfile;
#endif
PyEval_RestoreThread(event_tstate);
PyEval_RestoreThread(st->event_tstate);
st->stdin_ready = 0;
st->errorInCmd = 0;
#ifndef MS_WINDOWS
Expand All @@ -3228,7 +3226,7 @@ EventHook(void)
if (st->tcl_lock) {
PyThread_acquire_lock(st->tcl_lock, 1);
}
tcl_tstate = event_tstate;
tcl_tstate = st->event_tstate;

result = Tcl_DoOneEvent(TCL_DONT_WAIT);

Expand Down Expand Up @@ -3263,7 +3261,8 @@ EnableEventHook(void)
{
#ifdef WAIT_FOR_STDIN
if (PyOS_InputHook == NULL) {
event_tstate = PyThreadState_Get();
module_state *st = GLOBAL_STATE();
st->event_tstate = PyThreadState_Get();
PyOS_InputHook = EventHook;
}
#endif
Expand Down
1 change: 1 addition & 0 deletions Modules/tkinter.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ typedef struct {
int Tkinter_busywaitinterval;
struct _fhcdata *HeadFHCD;
int stdin_ready;
PyThreadState *event_tstate;
} module_state;

extern module_state global_state;
Expand Down
1 change: 0 additions & 1 deletion Tools/c-analyzer/cpython/globals-to-fix.tsv
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,6 @@ Modules/_ssl/debughelpers.c _PySSL_keylog_callback lock -
Modules/_tkinter.c - call_mutex -
Modules/_tkinter.c - var_mutex -
Modules/_tkinter.c - command_mutex -
Modules/_tkinter.c - event_tstate -
Modules/_xxinterpchannelsmodule.c - _globals -
Modules/readline.c - completer_word_break_characters -
Modules/readline.c - _history_length -
Expand Down