Skip to content

Commit 5b2634e

Browse files
committed
Fix handling of set()
1 parent 9b7009f commit 5b2634e

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

bpython/simpleeval.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,8 @@ def _convert(node):
111111
elif isinstance(node, ast.Set):
112112
return set(map(_convert, node.elts))
113113
elif (
114-
isinstance(node, Call)
115-
and isinstance(node.func, Name)
114+
isinstance(node, ast.Call)
115+
and isinstance(node.func, ast.Name)
116116
and node.func.id == "set"
117117
and node.args == node.keywords == []
118118
):

bpython/test/test_simpleeval.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import ast
44
import numbers
5+
import sys
56

67
from bpython.simpleeval import (
78
simple_eval,
@@ -25,6 +26,10 @@ def test_matches_stdlib(self):
2526
def test_matches_stdlib_py3(self):
2627
"""Should match the stdlib literal_eval if no names or indexing"""
2728
self.assertMatchesStdlib("{1, 2}")
29+
30+
@unittest.skipUnless(sys.version_info[:2] >= (3, 9), "Only Python3.9 evaluates set()")
31+
def test_matches_stdlib_set_literal(self):
32+
"""set() is evaluated"""
2833
self.assertMatchesStdlib("set()")
2934

3035
def test_indexing(self):

0 commit comments

Comments
 (0)