Skip to content

Commit cc43f00

Browse files
committed
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.
1 parent fd4f032 commit cc43f00

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

setup.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,12 @@ def default_environment():
9393
if (len(a.targets) == 1 and
9494
isinstance(a.targets[0], ast.Name) and
9595
a.targets[0].id == "__version__" and
96-
isinstance(a.value, ast.Str)):
97-
version = a.value.s
96+
(
97+
(hasattr(ast, "Str") and isinstance(a.value, ast.Str)) or
98+
(isinstance(a.value, ast.Constant) and isinstance(a.value.value, str))
99+
)
100+
):
101+
version = getattr(a.value, "s", a.value.value)
98102

99103
setup(name='html5lib',
100104
version=version,

0 commit comments

Comments
 (0)