On Fri, 3 Sep 2021 at 19:04, Stefan Monnier wrote: >> Change Python eval to send directly instead of using temporary files > > FWIW, sending large amounts of text via pty can be troublesome (some > OSes have been known to insert additional control chars every 256 > bytes, or to do weird things after 4096 bytes leading the send to never > complete, ...), which is why it's very common for comint modes to send > regions of text via temp files. > > > Stefan Okay, the 4096 bytes limit indeed exists in IPython (but not in the standard Python interpreters, apparently). I've attached a patch that reverts to using temporary files for sufficiently long strings (would this magic 4096 ever require customization?). The patch also solves bug#32042, which is mostly unrelated. I would like pass text inline as much as possible because the back-and-forth of temp files is pretty slow over Tramp, which makes the Python shell rather annoying to use. As to some OSes inserting additional control characters every 256 bytes, I've never encountered this, but it seems a rather tricky problem to work around. Before this commit, the "plumbing code" sent to the interpreter could already be above 256 bytes (e.g., if the generated temp file names are modestly long). Inserting newline characters at strategic places would print random prompt strings, and therefore also introduce complications.