Skip to content

Commit 49fe652

Browse files
committed
utils/gen: remove _OLD_AST fallback for Python < 3.8
1 parent e9778b6 commit 49fe652

File tree

1 file changed

+1
-11
lines changed

1 file changed

+1
-11
lines changed

src/utils/gen.py

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -167,9 +167,6 @@ def saltHash(password, salt=None, hash='sha'):
167167
hasher = crypt.md5
168168
return '|'.join([salt, hasher((salt + password).encode('utf8')).hexdigest()])
169169

170-
_OLD_AST = sys.version_info[0:2] < (3, 8)
171-
"""Whether the AST classes predate the python 3.8 API changes"""
172-
173170
def safeEval(s, namespace=None):
174171
"""Evaluates s, safely. Useful for turning strings into tuples/lists/etc.
175172
without unsafely using eval()."""
@@ -181,7 +178,7 @@ def safeEval(s, namespace=None):
181178
def checkNode(node):
182179
if node.__class__ is ast.Expr:
183180
node = node.value
184-
if not _OLD_AST and node.__class__ is ast.Constant:
181+
if node.__class__ is ast.Constant:
185182
return True
186183
elif node.__class__ in (ast.List,
187184
ast.Tuple):
@@ -197,13 +194,6 @@ def checkNode(node):
197194
return True
198195
else:
199196
return False
200-
elif _OLD_AST and node.__class__ in (ast.Num, ast.Str, ast.Bytes):
201-
# ast.Num, ast.Str, ast.Bytes are deprecated since Python 3.8
202-
# and removed since Python 3.14; replaced by ast.Constant.
203-
return True
204-
elif _OLD_AST and node.__class__ is ast.NameConstant:
205-
# ditto
206-
return True
207197
else:
208198
return False
209199
if checkNode(node):

0 commit comments

Comments
 (0)