Fix #347

Added a test and made safe_eval (in autocomplete.py) catch syntax errors.