At 04:34 PM 4/15/01 +0000, Davide Alberani wrote: >I need to prevent a function (called via r_eval()) to import the sys >module and then call sys.exit(). Read *all* of the rexec module documentation at http://www.python.org/doc/current/lib/module-rexec.html >Sample code: > >my_dict = {'exported_var': a_var, ... } > >class MyRE(rexec.RExec): > def r_eval(self, code): > return eval(code, my_dict) MyRE.ok_sys_names = () # or some names you wish to allow >myr = MyRE() > >myr.r_eval(function_code) and don't forget r_exec(). >Now, if function_code contains "import sys ; sys.exit()", the program >terminates. With MyRE.ok_sys_names == (), sys.exit will raise an AttributeError. -- Robin Thomas Engineering StarMedia Network, Inc. robin.thomas at starmedia.net
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4