Skip to content

gh-140146: Fix for stdin redirection to a pipe with interactive tkinter on Windows#148819

Merged
serhiy-storchaka merged 9 commits into
python:mainfrom
mdehoon:issue140146_fix_for_windows_pipe
Jun 29, 2026
Merged

gh-140146: Fix for stdin redirection to a pipe with interactive tkinter on Windows#148819
serhiy-storchaka merged 9 commits into
python:mainfrom
mdehoon:issue140146_fix_for_windows_pipe

Conversation

@mdehoon

@mdehoon mdehoon commented Apr 21, 2026

Copy link
Copy Markdown
Contributor

On Windows, EventHook in _tkinter.c will hang on Windows if Python is run with stdin redirected to a pipe. The reason is that on Windows, EventHook checks for data availability on stdin by calling _kbhit, which reports if a key was hit on the keyboard. With this patch, EventHook first checks whether stdin is a console or a pipe, and then calls either _kbhit or PeekNamedPipe, respectively, to establish if input is available on stdin.

@serhiy-storchaka

Copy link
Copy Markdown
Member

@mdehoon, please resolve conflict.

mdehoon added 2 commits June 29, 2026 09:04
Remove errorInCmd as a condition for the while-loop, as #pythongh-139145 has now been merged.
@mdehoon

mdehoon commented Jun 29, 2026

Copy link
Copy Markdown
Contributor Author

@serhiy-storchaka

@mdehoon, please resolve conflict.

Done.

Comment thread Modules/_tkinter.c
Comment thread Misc/NEWS.d/next/Windows/2026-04-21-16-07-11.gh-issue-140146.TAcUHA.rst Outdated
Comment thread Lib/test/test_tkinter/test_tkinter_pipe.py Outdated
Comment thread Lib/test/test_tkinter/test_tkinter_pipe.py Outdated
mdehoon and others added 4 commits June 29, 2026 17:13
Adding a breaking arm for FILE_TYPE_DISK (python -i < file), as a disk file is always readable.
…AcUHA.rst

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
If the test fails, let it fail quickly.

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
If the test fails, let it fail quickly.

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>

@serhiy-storchaka serhiy-storchaka left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. 👍

Thanks for handling the rebase and the follow-ups.

@serhiy-storchaka serhiy-storchaka enabled auto-merge (squash) June 29, 2026 08:37
@serhiy-storchaka serhiy-storchaka added needs backport to 3.13 bugs and security fixes needs backport to 3.14 bugs and security fixes needs backport to 3.15 pre-release feature fixes, bugs and security fixes labels Jun 29, 2026
@serhiy-storchaka serhiy-storchaka merged commit 6d209cb into python:main Jun 29, 2026
64 checks passed
@miss-islington-app

Copy link
Copy Markdown

Thanks @mdehoon for the PR, and @serhiy-storchaka for merging it 🌮🎉.. I'm working now to backport this PR to: 3.13, 3.14, 3.15.
🐍🍒⛏🤖 I'm not a witch! I'm not a witch!

@bedevere-app

bedevere-app Bot commented Jun 29, 2026

Copy link
Copy Markdown

GH-152560 is a backport of this pull request to the 3.15 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.15 pre-release feature fixes, bugs and security fixes label Jun 29, 2026
@bedevere-app

bedevere-app Bot commented Jun 29, 2026

Copy link
Copy Markdown

GH-152561 is a backport of this pull request to the 3.14 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.14 bugs and security fixes label Jun 29, 2026
@bedevere-app

bedevere-app Bot commented Jun 29, 2026

Copy link
Copy Markdown

GH-152562 is a backport of this pull request to the 3.13 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.13 bugs and security fixes label Jun 29, 2026
serhiy-storchaka pushed a commit that referenced this pull request Jun 29, 2026
…e tkinter on Windows (GH-148819) (GH-152562)

(cherry picked from commit 6d209cb)

Co-authored-by: mdehoon <mjldehoon@yahoo.com>
serhiy-storchaka pushed a commit that referenced this pull request Jun 29, 2026
…e tkinter on Windows (GH-148819) (GH-152561)

(cherry picked from commit 6d209cb)

Co-authored-by: mdehoon <mjldehoon@yahoo.com>
serhiy-storchaka pushed a commit that referenced this pull request Jun 29, 2026
…e tkinter on Windows (GH-148819) (GH-152560)

(cherry picked from commit 6d209cb)

Co-authored-by: mdehoon <mjldehoon@yahoo.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants