Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit fe7fa6c

Browse filesBrowse files
Merge pull request bpython#348 from mlauter/fix-347
Fix bpython#347
2 parents b770323 + ce4ab58 commit fe7fa6c
Copy full SHA for fe7fa6c

2 files changed

+7-1Lines changed: 7 additions & 1 deletion

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎bpython/autocomplete.py‎

Copy file name to clipboardExpand all lines: bpython/autocomplete.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ def safe_eval(expr, namespace):
342342
try:
343343
obj = eval(expr, namespace)
344344
return obj
345-
except (NameError, AttributeError) as e:
345+
except (NameError, AttributeError, SyntaxError) as e:
346346
# If debugging safe_eval, raise this!
347347
# raise e
348348
return SafeEvalFailed
Collapse file

‎bpython/test/test_autocomplete.py‎

Copy file name to clipboardExpand all lines: bpython/test/test_autocomplete.py
+6Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@ def test_cw(self):
3434
self.assertEqual(self.repl.cw(), 'datetime')
3535
"""
3636

37+
class TestSafeEval(unittest.TestCase):
38+
def test_catches_syntax_error(self):
39+
try:
40+
autocomplete.safe_eval('1re',{})
41+
except:
42+
self.fail('safe_eval raises an error')
3743

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

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.