diff options
| author | Harry (Open ERP) <hmo@tinyerp.com> | 2009-11-24 20:14:05 +0530 |
|---|---|---|
| committer | Harry (Open ERP) <hmo@tinyerp.com> | 2009-11-24 20:14:05 +0530 |
| commit | d8ce3f1e2a5a55f0c28eb1cf8cb4cfcd2d6d5dab (patch) | |
| tree | f1dbd61528db0d90cebb5f2b5e4e836f00f71aef /bin/tools/safe_eval.py | |
| parent | dda5ed6bb1710e4690c1e01fe4265cc7db147068 (diff) | |
[FIX] replaced <TAB> with four white space.
bzr revid: hmo@tinyerp.com-20091124144405-9mzd91chohvf0uu7
Diffstat (limited to 'bin/tools/safe_eval.py')
| -rw-r--r-- | bin/tools/safe_eval.py | 58 |
1 files changed, 29 insertions, 29 deletions
diff --git a/bin/tools/safe_eval.py b/bin/tools/safe_eval.py index 7c4da78375c..bfbc0b34fe9 100644 --- a/bin/tools/safe_eval.py +++ b/bin/tools/safe_eval.py @@ -29,38 +29,38 @@ __export_bis = {} import sys def __init_ebis(): - global __export_bis - - _evars = [ 'abs', 'all', 'any', 'basestring' , 'bool', - 'chr', 'cmp','complex', 'dict', 'divmod', 'enumerate', - 'float', 'frozenset', 'getattr', 'hasattr', 'hash', - 'hex', 'id','int', 'iter', 'len', 'list', 'long', 'map', 'max', - 'min', 'oct', 'ord','pow', 'range', 'reduce', 'repr', - 'reversed', 'round', 'set', 'setattr', 'slice','sorted', 'str', - 'sum', 'tuple','type', 'unichr','unicode', 'xrange', - 'True','False', 'None', 'NotImplemented', 'Ellipsis', ] - - if sys.version_info[0:2] >= (2,6): - _evars.extend(['bin', 'format', 'next']) - for v in _evars: - __export_bis[v] = __builtins__[v] - + global __export_bis + + _evars = [ 'abs', 'all', 'any', 'basestring' , 'bool', + 'chr', 'cmp','complex', 'dict', 'divmod', 'enumerate', + 'float', 'frozenset', 'getattr', 'hasattr', 'hash', + 'hex', 'id','int', 'iter', 'len', 'list', 'long', 'map', 'max', + 'min', 'oct', 'ord','pow', 'range', 'reduce', 'repr', + 'reversed', 'round', 'set', 'setattr', 'slice','sorted', 'str', + 'sum', 'tuple','type', 'unichr','unicode', 'xrange', + 'True','False', 'None', 'NotImplemented', 'Ellipsis', ] + + if sys.version_info[0:2] >= (2,6): + _evars.extend(['bin', 'format', 'next']) + for v in _evars: + __export_bis[v] = __builtins__[v] + __init_ebis() def safe_eval(expr,sglobals,slocals = None): - """ A little safer version of eval(). - This one, will use fewer builtin functions, so that only - arithmetic and logic expressions can really work """ - - global __export_bis + """ A little safer version of eval(). + This one, will use fewer builtin functions, so that only + arithmetic and logic expressions can really work """ + + global __export_bis - if not sglobals.has_key('__builtins__'): - # we copy, because we wouldn't want successive calls to safe_eval - # to be able to alter the builtins. - sglobals['__builtins__'] = __export_bis.copy() - - return eval(expr,sglobals,slocals) - -#eof
\ No newline at end of file + if not sglobals.has_key('__builtins__'): + # we copy, because we wouldn't want successive calls to safe_eval + # to be able to alter the builtins. + sglobals['__builtins__'] = __export_bis.copy() + + return eval(expr,sglobals,slocals) + +#eof |
