Restricted Execution
Normally, a Python program has complete access to the machine on which it runs. In particular, it can open files and network connections, and perform other potentially sensitive operations. In certain applications, however, this is undesirable—especially in Internet applications, in which a program may be subject to attackers or when code from an untrusted source is executed.
To provide some measure of safety, Python provides support for restricted execution. Restricted execution is based on the notion of separating trusted and untrusted code. In particular, a program running in trusted mode (a supervisor) can create an execution environment (or sandbox) in which untrusted code can be executed with limited privileges. The ...
Get Python Essential Reference, Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.