Subject: Re: bug#55119: 27.2; Inferior Python/ M-x run-python problem with Tk on Windows

From: Eli Zaretskii <[email-masked]>
Date: Tue, 26 Apr 2022 14:14:02 +0300

> From: Robert Thorpe <[email-masked]>
> Date: Tue, 26 Apr 2022 05:03:58 +0100
> 
> I have a problem with M-x run-python on Windows 10 enterprise.
> 
> The python code I'm working on uses Tk.  Unfortunately, after Tk is used
> the inferior python no longer responds to inputs.  I see one more
> prompt, then nothing at all.
> 
> Type the following into an inferior python process.  Or alternatively,
> put it in a file and import it.
> 
> import tkinter as tk
> from tkinter import ttk
> window = tk.Tk()
> 
> This pops up a Tk window with nothing in it.  It also gives another
> python prompt.  But after that communication between Emacs and the
> inferior python process seems to be lost.

Unless there's someone here who uses this configuration on Windows,
knows the details, and can dig into the problem, you'll have to tell
more about what the above does, from the technical POV.  It is likely
some snafu with I/O between Emacs and Python when it uses Tcl/Tk, but
what exactly and whether it's at all solvable, is anybody's guess at
this point.  All I can tell you is that Emacs on Windows uses a
bidirectional pipe to communicate with subprocesses, so if the above
fiddles with standard I/O streams in some non-trivial ways, or assumes
it can separate input device from output device, or redirect them
separately to different places, or even that one or both of them are
or can be made unbuffered -- it will simply fail to work on Windows.
You have a single bidirectional pipe which is buffered by the OS, and
at least Python (or any other external program) will see that its
standard I/O is not connected to a console device, and will
(mis)behave accordingly.

The buffering issue you could perhaps deal with, by telling Python to
use unbuffered I/O.  But I'm not even sure this is the root cause of
what you see.

That is all I can tell without more detail, sorry.