settings.py: Support newer `ast.Constant' for settings.txt file.

In python 3.8, specific constant AST types are removed in favor of
ast.Constant. This change should work for both cases. See
https://bugs.python.org/issue32892 for the given rationale.
This commit is contained in:
Jelle Licht 2020-09-05 20:41:21 +02:00
parent c084caf492
commit 799177d651
No known key found for this signature in database
GPG Key ID: DA4597F947B41025

View File

@ -235,6 +235,7 @@ else:
# parse settings in a safe way, without exec
settings = {}
attributes = {
ast.Constant: 'value',
ast.NameConstant: 'value',
ast.Num: 'n',
ast.Str: 's',
@ -258,7 +259,7 @@ else:
log_ignored_line(node.lineno, target.id + " is not a valid setting")
continue
if type(node.value) not in (ast.NameConstant, ast.Num, ast.Str):
if type(node.value) not in attributes:
log_ignored_line(node.lineno, "only literals allowed for values")
continue