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 c538115

Browse filesBrowse files
Fix Python 3.3 build
apparently ast.NameConstant was added in 3.4
1 parent 246a5ee commit c538115
Copy full SHA for c538115

1 file changed

+6-1Lines changed: 6 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/simpleeval.py‎

Copy file name to clipboardExpand all lines: bpython/simpleeval.py
+6-1Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,14 @@ def simple_eval(node_or_string, namespace=None):
8181
node_or_string = node_or_string.body
8282

8383
string_type_nodes = (ast.Str, ast.Bytes) if py3 else (ast.Str,)
84-
name_type_nodes = (ast.Name, ast.NameConstant) if py3 else (ast.Name,)
8584
numeric_types = (int, float, complex) + (() if py3 else (long,))
8685

86+
# added in Python 3.4
87+
if hasattr(ast, 'NameConstant'):
88+
name_type_nodes = (ast.Name, ast.NameConstant)
89+
else:
90+
name_type_nodes = (ast.Name,)
91+
8792
def _convert(node):
8893
if isinstance(node, string_type_nodes):
8994
return node.s

0 commit comments

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