From cc43f00d121ef13f018f0d8c09872d0ea2a8ed9c Mon Sep 17 00:00:00 2001 From: Andrew Sukach Date: Fri, 12 Sep 2025 21:53:31 -0700 Subject: [PATCH] `setup.py`: fix version parsing on Python 3.14 (ast.Str removed) Python 3.14 removes the ast.Str node type. String literals now appear as ast.Constant(value=str). Update the AST check to accept both ast.Str (for older Pythons) and ast.Constant with a string value (for Python 3.8+), allowing html5lib to build successfully on Python 3.14 while remaining compatible with older version. --- setup.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index 30ee0575..d4a572a5 100644 --- a/setup.py +++ b/setup.py @@ -93,8 +93,12 @@ def default_environment(): if (len(a.targets) == 1 and isinstance(a.targets[0], ast.Name) and a.targets[0].id == "__version__" and - isinstance(a.value, ast.Str)): - version = a.value.s + ( + (hasattr(ast, "Str") and isinstance(a.value, ast.Str)) or + (isinstance(a.value, ast.Constant) and isinstance(a.value.value, str)) + ) + ): + version = getattr(a.value, "s", a.value.value) setup(name='html5lib', version=version,