| 1 | Patch-Source: https://github.com/html5lib/html5lib-python/pull/589 |
| 2 | |
| 3 | From b90dafff1bf342d34d539098013d0b9f318c7641 Mon Sep 17 00:00:00 2001 |
| 4 | From: Andrew Sukach <[email protected]> |
| 5 | Date: Fri, 12 Sep 2025 21:53:31 -0700 |
| 6 | Subject: [PATCH] `setup.py`: fix version parsing on Python 3.14 (ast.Str |
| 7 | removed) |
| 8 | |
| 9 | Python 3.14 removes the ast.Str node type. String literals now appear |
| 10 | as ast.Constant(value=str). |
| 11 | Update the AST check to accept both ast.Str (for older Pythons) and |
| 12 | ast.Constant with a string value (for Python 3.8+), allowing html5lib to |
| 13 | build successfully on Python 3.14 while remaining compatible with older |
| 14 | version. |
| 15 | |
| 16 | setup.py | 11 ++++++++--- |
| 17 | 1 file changed, 8 insertions(+), 3 deletions(-) |
| 18 | |
| 19 | diff --git a/setup.py b/setup.py |
| 20 | index 30ee0575..42ab6f67 100644 |
| 21 | |
| 22 | |
| 23 | def default_environment(): |
| 24 | for a in assignments: |
| 25 | if (len(a.targets) == 1 and |
| 26 | isinstance(a.targets[0], ast.Name) and |
| 27 | - a.targets[0].id == "__version__" and |
| 28 | - isinstance(a.value, ast.Str)): |
| 29 | - version = a.value.s |
| 30 | + a.targets[0].id == "__version__"): |
| 31 | + if hasattr(ast, "Str") and isinstance(a.value, ast.Str): |
| 32 | + version = a.value.s |
| 33 | + elif (hasattr(ast, "Constant") |
| 34 | + and isinstance(a.value, ast.Constant) |
| 35 | + and isinstance(a.value.value, str)): |
| 36 | + version = a.value.value |
| 37 | +assert version is not None |
| 38 | |
| 39 | setup(name='html5lib', |
| 40 | version=version, |