# -*- coding: utf-8 -*-
##############################################################################
-# Copyright (C) 2004-2010 OpenERP s.a. (<http://www.openerp.com>).
+# Copyright (C) 2004-2012 OpenERP s.a. (<http://www.openerp.com>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
import logging
import os
-__all__ = ['test_expr', 'safe_eval', 'const_eval', 'ext_eval' ]
+__all__ = ['test_expr', 'safe_eval', 'const_eval']
# 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
_CONST_OPCODES = set(opmap[x] for x in [
'POP_TOP', 'ROT_TWO', 'ROT_THREE', 'ROT_FOUR', 'DUP_TOP', 'DUP_TOPX',
'POP_BLOCK','SETUP_LOOP', 'BUILD_LIST', 'BUILD_MAP', 'BUILD_TUPLE',
- 'LOAD_CONST', 'RETURN_VALUE', 'STORE_SUBSCR'] if x in opmap)
+ 'LOAD_CONST', 'RETURN_VALUE', 'STORE_SUBSCR', 'STORE_MAP', 'LOAD_NAME'] if x in opmap)
_EXPR_OPCODES = _CONST_OPCODES.union(set(opmap[x] for x in [
'UNARY_POSITIVE', 'UNARY_NEGATIVE', 'UNARY_NOT',
'set' : set
}
)
- return eval(test_expr(expr,_SAFE_OPCODES, mode=mode), globals_dict, locals_dict)
+ try:
+ return eval(test_expr(expr, _SAFE_OPCODES, mode=mode), globals_dict, locals_dict)
+ except Exception:
+ _logger.exception('Cannot eval %r', expr)
+ raise
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: