File tree Expand file tree Collapse file tree 1 file changed +2
-7
lines changed Expand file tree Collapse file tree 1 file changed +2
-7
lines changed Original file line number Diff line number Diff line change 42
42
43
43
_string_type_nodes = (ast .Str , ast .Bytes ) if py3 else (ast .Str ,)
44
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 ,)
45
+ _name_type_nodes = (ast .Name , ast .NameConstant ) if py3 else (ast .Name ,)
51
46
52
47
53
48
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
98
if isinstance (node , _string_type_nodes ):
104
99
return node .s
You can’t perform that action at this time.
0 commit comments