<div dir="ltr"><div>Hi James,<br></div><div><br></div><div>IDLE's use of a sub-process is not primarily about security.</div><div><br></div><div>If one were to run user code within the same Python process (as IDLE originally did!), then the Python interpreter would be shared between the user code and IDLE. <br></div><div><br></div><div>(It is today possible to run a (nearly entirely) separate Python interpreter within the same process, but that is a relatively new development from recent years.)</div><div><br></div><div>Sharing the interpreter is a problem for various reasons, led by:</div><div>* User code can break IDLE in many interesting and unexpected ways.<br></div><div>* User code can block the main thread, which would make IDLE unresponsive.<br></div><div><br></div><div>There are many other reasons too. For example, the "restart interpreter" feature is much harder, perhaps impossible, to implement.</div><div><br></div><div>Let me know if you'd like any further details.</div><div>- Tal Einat<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, May 23, 2023 at 1:23 AM James Schaffler via IDLE-dev <<a href="mailto:idle-dev@python.org">idle-dev@python.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi,<br>
<br>
I was curious about the internals of IDLE, and noticed that IDLE uses executes user code in a "subprocess" that's separate from the Python interpreter that is running IDLE itself (which does tasks such as making the window and coloring the text).<br>
<br>
As far as I understand, IDLE runs a modified version of code.InteractiveInterpreter by sending user code through a socket. Even the IDLE documentation says that without a subprocess, "user code is not isolated from IDLE itself." However, some minimal testing of InteractiveInterpreter leads me to believe that the Interpreter object has its own view of local/global variables and therefore shouldn't be able to affect the calling interpreter (please correct me if I'm wrong).<br>
<br>
So my question is a combination of "Why does IDLE use a subprocess?" and "Why is InteractiveInterpreter not secure enough?" What possible security vulnerabilities exist if one uses IDLE without the subprocess? If anyone knows (or could point me to information on) why IDLE is designed this way, I'd really appreciate it. Thank you!<br>
<br>
Jim<br>
_______________________________________________<br>
IDLE-dev mailing list<br>
<a href="mailto:IDLE-dev@python.org" target="_blank">IDLE-dev@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/idle-dev" rel="noreferrer" target="_blank">https://mail.python.org/mailman/listinfo/idle-dev</a><br>
</blockquote></div>