-
-
Notifications
You must be signed in to change notification settings - Fork 30.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PyOS_InputHook is not called when waiting for input() in Windows #75727
Comments
Since python 3.6, PyOS_InputHook is not called when waiting for IO in Windows. This causes issues with GUI framework like tkinter that relys on PyOS_InputHook to handle user interaction. I attached a test script. When running the script with python 3.5, the tkinter window will show up properly. But if you run the script with python 3.6, the tkinter window will be frozen. I believe the issue is introduced in commit 3929499. In commit 3929499, _PyOS_WindowsConsoleReadline is added as the new Windows implementation of PyOS_StdioReadline. Originally, PyOS_StdioReadline calls my_fgets to read input, and my_fgets will call PyOS_InputHook before the calling the real fgets. However, _PyOS_WindowsConsoleReadline calls ReadConsoleW instead of my_fgets to read input, and PyOS_InputHook is never called. The bug is first reported in matplotlib. |
Attach python 3.5 call stack of the test script |
Attach python 3.6 call stack of the test script |
You're right, we're missing this section of code:
Since we just call it and ignore anything it does, it should be safe enough to add it immediately before the ReadConsoleW call (inside the loop). |
(Belongs inside Parser/myreadline.c in the _PyOS_WindowsConsoleReadline function) |
As the fix seems simple, any chance this bug can be fixed in next python 3.6 maintenance release? It is the major roadblock for my application to upgrade to python 3.6. Thanks |
The fix is simple, just need someone to do a PR. (I might get to it eventually, but I'm working on other things right now.) |
And yes, I think this is fine for 3.6. |
Can this issue be closed? PR 7978 was merged and backported. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: