Skip to content

Commit baa92a0

Browse files
committed
Handle Subscript nodes with slices of type ast.Constant
This partly fixes bpython#809
1 parent 99c601a commit baa92a0

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

bpython/simpleeval.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,12 @@ def _convert(node):
160160
obj = _convert(node.value)
161161
index = _convert(node.slice.value)
162162
return safe_getitem(obj, index)
163+
elif sys.version_info[:2] >= (3, 9) and isinstance(node, ast.Subscript) and isinstance(
164+
node.slice, ast.Constant
165+
):
166+
obj = _convert(node.value)
167+
index = node.slice.value
168+
return safe_getitem(obj, index)
163169

164170
# this is a deviation from literal_eval: we allow attribute access
165171
if isinstance(node, ast.Attribute):

0 commit comments

Comments
 (0)