diff --git a/OMPython/OMTypedParser.py b/OMPython/OMTypedParser.py index 56eb2e7..b4f0d24 100644 --- a/OMPython/OMTypedParser.py +++ b/OMPython/OMTypedParser.py @@ -93,11 +93,11 @@ def convertTuple(t): def evaluateExpression(s, loc, toks): # Convert the tokens (ParseResults) into a string expression flat_list = [item for sublist in toks[0] for item in sublist] - expr = " ".join(flat_list) + expr = "".join(flat_list) try: # Evaluate the expression safely return eval(expr) - except NameError: + except Exception: return expr # Number parsing (supports arithmetic expressions in dimensions) (e.g., {1 + 1, 1}) diff --git a/tests/test_ArrayDimension.py b/tests/test_ArrayDimension.py index 8ecb268..0987727 100644 --- a/tests/test_ArrayDimension.py +++ b/tests/test_ArrayDimension.py @@ -30,7 +30,7 @@ def test_ArrayDimension(self): omc.sendExpression("getErrorString()") result = omc.sendExpression("getComponents(A)") - assert result[-1][-1] == ('y + 1', 10), f"array dimension does not match the expected value. Got: {result[-1][-1]}, Expected: {('y + 1', 10)}" + assert result[-1][-1] == ('y+1', 10), f"array dimension does not match the expected value. Got: {result[-1][-1]}, Expected: {('y+1', 10)}" omc.__del__() shutil.rmtree(tempdir, ignore_errors= True)