@@ -884,7 +884,7 @@ def validate(ex: str,
884
884
except KeyError :
885
885
compiled_ex = _numexpr_cache [numexpr_key ] = NumExpr (ex , signature , sanitize = sanitize , ** context )
886
886
kwargs = {'out' : out , 'order' : order , 'casting' : casting ,
887
- 'ex_uses_vml' : ex_uses_vml }
887
+ 'ex_uses_vml' : ex_uses_vml }
888
888
_numexpr_last .set (ex = compiled_ex , argnames = names , kwargs = kwargs )
889
889
except Exception as e :
890
890
return e
@@ -943,9 +943,9 @@ def evaluate(ex: str,
943
943
* 'unsafe' means any data conversions may be done.
944
944
945
945
sanitize: bool
946
- Both `validate` and by extension `evaluate` call `eval(ex)`, which is
947
- potentially dangerous on unsanitized inputs. As such, NumExpr by default
948
- performs simple sanitization, banning the character ':;[', the
946
+ `validate` ( and by extension `evaluate`) call `eval(ex)`, which is
947
+ potentially dangerous on non-sanitized inputs. As such, NumExpr by default
948
+ performs simple sanitization, banning the characters ':;[', the
949
949
dunder '__[\w+]__', and attribute access to all but '.real' and '.imag'.
950
950
951
951
Using `None` defaults to `True` unless the environment variable
@@ -956,15 +956,9 @@ def evaluate(ex: str,
956
956
The calling frame depth. Unless you are a NumExpr developer you should
957
957
not set this value.
958
958
959
- Note
960
- ----
961
- Both `validate` and by extension `evaluate` call `eval(ex)`, which is
962
- potentially dangerous on unsanitized inputs. As such, NumExpr does some
963
- sanitization, banning the character ':;[', the dunder '__', and attribute
964
- access to all but '.r' for real and '.i' for imag access to complex numbers.
965
959
"""
966
960
# We could avoid code duplication if we called validate and then re_evaluate
967
- # here, but they we have difficulties with the `sys.getframe(2)` call in
961
+ # here, but we have difficulties with the `sys.getframe(2)` call in
968
962
# `getArguments`
969
963
e = validate (ex , local_dict = local_dict , global_dict = global_dict ,
970
964
out = out , order = order , casting = casting ,
0 commit comments