Skip to content

Commit 660cd66

Browse files
committed
Simplify version checks
1 parent 6fcc768 commit 660cd66

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

bpython/simpleeval.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,7 @@
4242

4343
_string_type_nodes = (ast.Str, ast.Bytes) if py3 else (ast.Str,)
4444
_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,)
45+
_name_type_nodes = (ast.Name, ast.NameConstant) if py3 else (ast.Name,)
5146

5247

5348
class EvaluationError(Exception):
@@ -98,7 +93,7 @@ def simple_eval(node_or_string, namespace=None):
9893
node_or_string = node_or_string.body
9994

10095
def _convert(node):
101-
if sys.version_info[:2] >= (3, 6) and isinstance(node, ast.Constant):
96+
if py3 and isinstance(node, ast.Constant):
10297
return node.value
10398
if isinstance(node, _string_type_nodes):
10499
return node.s

0 commit comments

Comments
 (0)