We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 6fcc768 commit 660cd66Copy full SHA for 660cd66
1 file changed
bpython/simpleeval.py
@@ -42,12 +42,7 @@
42
43
_string_type_nodes = (ast.Str, ast.Bytes) if py3 else (ast.Str,)
44
_numeric_types = (int, float, complex) + (() if py3 else (long,))
45
-
46
-# added in Python 3.4
47
-if hasattr(ast, "NameConstant"):
48
- _name_type_nodes = (ast.Name, ast.NameConstant)
49
-else:
50
- _name_type_nodes = (ast.Name,)
+_name_type_nodes = (ast.Name, ast.NameConstant) if py3 else (ast.Name,)
51
52
53
class EvaluationError(Exception):
@@ -98,7 +93,7 @@ def simple_eval(node_or_string, namespace=None):
98
93
node_or_string = node_or_string.body
99
94
100
95
def _convert(node):
101
- if sys.version_info[:2] >= (3, 6) and isinstance(node, ast.Constant):
96
+ if py3 and isinstance(node, ast.Constant):
102
97
return node.value
103
if isinstance(node, _string_type_nodes):
104
return node.s
0 commit comments