rexec and sys.exit()

Davide Alberani alberanid at bigfoot.togli.questo.com
Sun Apr 15 12:34:24 EDT 2001


I need to prevent a function (called via r_eval()) to import the sys
module and then call sys.exit().

Sample code:

my_dict = {'exported_var': a_var, ... }

class MyRE(rexec.RExec):
    def r_eval(self, code):
        return eval(code, my_dict)

myr = MyRE()

myr.r_eval(function_code)


Now, if function_code contains "import sys ; sys.exit()", the program
terminates.


TIA,
-- 
http://digilander.iol.it/alberanid/



More information about the Python-list mailing list