[Idle-dev] Why does IDLE use a subprocess?

Tal Einat taleinat at gmail.com
Thu Jun 1 14:37:31 EDT 2023


Hi James,

IDLE's use of a sub-process is not primarily about security.

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.

(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.)

Sharing the interpreter is a problem for various reasons, led by:
* User code can break IDLE in many interesting and unexpected ways.
* User code can block the main thread, which would make IDLE unresponsive.

There are many other reasons too. For example, the "restart interpreter"
feature is much harder, perhaps impossible, to implement.

Let me know if you'd like any further details.
- Tal Einat

On Tue, May 23, 2023 at 1:23 AM James Schaffler via IDLE-dev <
idle-dev at python.org> wrote:

> Hi,
>
> 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).
>
> 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).
>
> 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!
>
> Jim
> _______________________________________________
> IDLE-dev mailing list
> IDLE-dev at python.org
> https://mail.python.org/mailman/listinfo/idle-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.python.org/pipermail/idle-dev/attachments/20230601/aec1bc89/attachment.html>


More information about the IDLE-dev mailing list