Skip to content

Fix #347 #348

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 13, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bpython/autocomplete.py
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ def safe_eval(expr, namespace):
try:
obj = eval(expr, namespace)
return obj
except (NameError, AttributeError) as e:
except (NameError, AttributeError, SyntaxError) as e:
# If debugging safe_eval, raise this!
# raise e
return SafeEvalFailed
Expand Down
6 changes: 6 additions & 0 deletions bpython/test/test_autocomplete.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ def test_cw(self):
self.assertEqual(self.repl.cw(), 'datetime')
"""

class TestSafeEval(unittest.TestCase):
def test_catches_syntax_error(self):
try:
autocomplete.safe_eval('1re',{})
except:
self.fail('safe_eval raises an error')

# make some fake files? Dependency inject? mock?
class TestFilenameCompletion(unittest.TestCase):
Expand Down