From 550457936ab8ef84fcc2bc809683fad375f3f6cf Mon Sep 17 00:00:00 2001 From: Jesus Date: Sat, 11 Apr 2026 12:43:17 -0500 Subject: [PATCH] fix(settings): add AST compatibility for Python 3.12+ * Use `ast.Constant` as primary node for Python 3.8+ * Maintain backward compatibility with `ast.Num`, `ast.Str`, and `ast.NameConstant` * Prevent crashes on Python 3.12 where legacy nodes were removed * Add safe handling via `try/except AttributeError` --- settings.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/settings.py b/settings.py index 25a5266..07511bd 100644 --- a/settings.py +++ b/settings.py @@ -499,12 +499,16 @@ else: else: # parse settings in a safe way, without exec current_settings_dict = {} + # Python 3.8+ uses ast.Constant; older versions use ast.Num, ast.Str, ast.NameConstant attributes = { ast.Constant: 'value', - ast.NameConstant: 'value', - ast.Num: 'n', - ast.Str: 's', } + try: + attributes[ast.Num] = 'n' + attributes[ast.Str] = 's' + attributes[ast.NameConstant] = 'value' + except AttributeError: + pass # Removed in Python 3.12+ module_node = ast.parse(settings_text) for node in module_node.body: if type(node) != ast.Assign: