Python eval error suppression

eval, python

Solution

To suppress `SyntaxError`:

try:
    eval("1 + 2) + 3")
except SyntaxError:
    pass

Problem

First off, I'm aware of eval's disadvantages and it will be used in an experiment I want to make only. I'm creating a script that works just like a Brute-Force algorithm but it won't break passwords but find the solution to a special form of an equation (more details are unnecessary). There will be lots of strings filled with (often syntactically incorrect) terms like 1+2)+3 - Is the only way to get the results of these terms via `eval`? - How to make python ignore syntactical errors occurring in `eval`? (The program shouldn't terminate)

Original source