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 stdin_ready into module state
  • Loading branch information
erlend-aasland committed Mar 29, 2023
commit 3d3e8818dba06e128fb6baa7dbdcd98e51105192
11 changes: 5 additions & 6 deletions Modules/_tkinter.c
Original file line number Diff line number Diff line change
Expand Up @@ -3191,13 +3191,12 @@ static PyMethodDef moduleMethods[] =

#ifdef WAIT_FOR_STDIN

static int stdin_ready = 0;

#ifndef MS_WINDOWS
static void
MyFileProc(void *clientData, int mask)
{
stdin_ready = 1;
module_state *st = GLOBAL_STATE();
st->stdin_ready = 1;
}
#endif

Expand All @@ -3211,17 +3210,17 @@ EventHook(void)
int tfile;
#endif
PyEval_RestoreThread(event_tstate);
stdin_ready = 0;
st->stdin_ready = 0;
st->errorInCmd = 0;
#ifndef MS_WINDOWS
tfile = fileno(stdin);
Tcl_CreateFileHandler(tfile, TCL_READABLE, MyFileProc, NULL);
#endif
while (!st->errorInCmd && !stdin_ready) {
while (!st->errorInCmd && !st->stdin_ready) {
int result;
#ifdef MS_WINDOWS
if (_kbhit()) {
stdin_ready = 1;
st->stdin_ready = 1;
break;
}
#endif
Expand Down
1 change: 1 addition & 0 deletions Modules/tkinter.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ typedef struct {
// Util
int Tkinter_busywaitinterval;
struct _fhcdata *HeadFHCD;
int stdin_ready;
} 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 - stdin_ready -
Modules/_tkinter.c - event_tstate -
Modules/_xxinterpchannelsmodule.c - _globals -
Modules/readline.c - completer_word_break_characters -
Expand Down