Skip to content

Commit b90daff

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 b90daff

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

setup.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,14 @@ def default_environment():
9292
for a in assignments:
9393
if (len(a.targets) == 1 and
9494
isinstance(a.targets[0], ast.Name) and
95-
a.targets[0].id == "__version__" and
96-
isinstance(a.value, ast.Str)):
97-
version = a.value.s
95+
a.targets[0].id == "__version__"):
96+
if hasattr(ast, "Str") and isinstance(a.value, ast.Str):
97+
version = a.value.s
98+
elif (hasattr(ast, "Constant")
99+
and isinstance(a.value, ast.Constant)
100+
and isinstance(a.value.value, str)):
101+
version = a.value.value
102+
assert version is not None
98103

99104
setup(name='html5lib',
100105
version=version,

0 commit comments

Comments
 (0)