diff --git a/numexpr/necompiler.py b/numexpr/necompiler.py index a693c4d..75bdaa2 100644 --- a/numexpr/necompiler.py +++ b/numexpr/necompiler.py @@ -265,7 +265,7 @@ def __str__(self): _flow_pat = r'[\;\[\:]' _dunder_pat = r'(^|[^\w])__[\w]+__($|[^\w])' -_attr_pat = r'\.\b(?!(real|imag|(\d*[eE]?[+-]?\d+)|\d*j)\b)' +_attr_pat = r'\.\b(?!(real|imag|(\d*[eE]?[+-]?\d+)|(\d*[eE]?[+-]?\d+j)|(\d*j))\b)' _blacklist_re = re.compile(f'{_flow_pat}|{_dunder_pat}|{_attr_pat}') def stringToExpression(s, types, context, sanitize: bool=True): diff --git a/numexpr/tests/test_numexpr.py b/numexpr/tests/test_numexpr.py index 2aa56ca..62210b4 100644 --- a/numexpr/tests/test_numexpr.py +++ b/numexpr/tests/test_numexpr.py @@ -583,6 +583,9 @@ def test_sanitize(self): evaluate('1.5j') evaluate('3.j') + #pass imaginary with scientific notation + evaluate('1.2e3+4.5e6j') + # pass forbidden characters within quotes x = np.array(['a', 'b'], dtype=bytes) evaluate("x == 'b:'")