From 65a3751613a392ae6a36f6efbcaeade924565d84 Mon Sep 17 00:00:00 2001 From: Vo Minh Thu Date: Tue, 22 Mar 2011 15:01:24 +0100 Subject: [PATCH] [FIX] safe_eval: added time in the allowed modules. - The reason is that on some older version of python (e.g. 2.5.2 on Windows), datetime.datetime.now() is doing an import time on itws own. lp bug: https://launchpad.net/bugs/703841 fixed bzr revid: vmt@openerp.com-20110322140124-huqn504k0y5xrkwa --- bin/tools/safe_eval.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/bin/tools/safe_eval.py b/bin/tools/safe_eval.py index 740b426f050..6c068d8fd78 100644 --- a/bin/tools/safe_eval.py +++ b/bin/tools/safe_eval.py @@ -39,7 +39,10 @@ import os __all__ = ['test_expr', 'literal_eval', 'safe_eval', 'const_eval', 'ext_eval' ] -_ALLOWED_MODULES = ['_strptime'] +# The time module is usually already provided in the safe_eval environment +# but some code, e.g. datetime.datetime.now() (Windows/Python 2.5.2, bug +# lp:703841), does import time. +_ALLOWED_MODULES = ['_strptime', 'time'] _CONST_OPCODES = set(opmap[x] for x in [ 'POP_TOP', 'ROT_TWO', 'ROT_THREE', 'ROT_FOUR', 'DUP_TOP','POP_BLOCK','SETUP_LOOP',