This module contains the RExec class, which supports r_exec(), r_eval(), r_execfile(), and r_import() methods, which are restricted versions of the standard Python functions exec(), eval(), execfile(), and the import statement. Code executed in this restricted environment will only have access to modules and functions that are deemed safe; you can subclass RExec to add or remove capabilities as desired.
Note: The RExec class can prevent code from performing unsafe operations like reading or writing disk files, or using TCP/IP sockets. However, it does not protect against code using extremely large amounts of memory or CPU time.
The RExec class has the following class attributes, which are used by the __init__ method. Changing them on an existing instance won't have any effect; instead, create a subclass of RExec and assign them new values in the class definition. Instances of the new class will then use those new values. All these attributes are tuples of strings.
RExec instances support the following methods:
Methods whose names begin with s_ are similar to the functions beginning with r_, but the code will be granted access to restricted versions of the standard I/O streans sys.stdin, sys.stderr, and sys.stdout.
RExec objects must also support various methods which will be implicitly called by code executing in the restricted environment. Overriding these methods in a subclass is used to change the policies enforced by a restricted environment.
And their equivalents with access to restricted standard I/O streams: