Commit 30d97076 authored by vpodpecan's avatar vpodpecan
Browse files

catch different exceptions during safe string evaluation

parent 2adaba72
......@@ -127,8 +127,10 @@ def base_safe_eval_string(input_dict):
sdata = str(input_dict['data'])
result = ast.literal_eval(sdata)
except Exception:
except ValueError:
raise Exception('Cannot evaluate string (remember, for safety reasons only literal structures can be evaluated: strings, numbers, tuples, lists, dicts, booleans, and None)')
except SyntaxError:
raise Exception('Invalid string! Please check all quotes, commas, ...')
return {'evaluation_result': result}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment