diff mbox series

[meta-python] python3-html5lib: Fix build with python 3.14

Message ID 20260120044653.339786-1-raj.khem@gmail.com
State New
Headers show
Series [meta-python] python3-html5lib: Fix build with python 3.14 | expand

Commit Message

Khem Raj Jan. 20, 2026, 4:46 a.m. UTC
Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
 ...sion-parsing-on-Python-3.14-ast.Str-.patch | 41 +++++++++++++++++++
 .../python/python3-html5lib_1.1.bb            |  1 +
 2 files changed, 42 insertions(+)
 create mode 100644 meta-python/recipes-devtools/python/python3-html5lib/0001-setup.py-fix-version-parsing-on-Python-3.14-ast.Str-.patch
diff mbox series

Patch

diff --git a/meta-python/recipes-devtools/python/python3-html5lib/0001-setup.py-fix-version-parsing-on-Python-3.14-ast.Str-.patch b/meta-python/recipes-devtools/python/python3-html5lib/0001-setup.py-fix-version-parsing-on-Python-3.14-ast.Str-.patch
new file mode 100644
index 0000000000..4d3c8eec91
--- /dev/null
+++ b/meta-python/recipes-devtools/python/python3-html5lib/0001-setup.py-fix-version-parsing-on-Python-3.14-ast.Str-.patch
@@ -0,0 +1,41 @@ 
+From 39db97412da6b9f4918ae1350ae9561be9af48ea Mon Sep 17 00:00:00 2001
+From: Andrew Sukach <andrew@sukach.org>
+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.
+
+Upstream-Status: Submitted [https://github.com/html5lib/html5lib-python/pull/589]
+Signed-off-by: Khem Raj <raj.khem@gmail.com>
+---
+ setup.py | 11 ++++++++---
+ 1 file changed, 8 insertions(+), 3 deletions(-)
+
+diff --git a/setup.py b/setup.py
+index f84c128..c393c9c 100644
+--- a/setup.py
++++ b/setup.py
+@@ -89,9 +89,14 @@ with open(join(here, "html5lib", "__init__.py"), "rb") as init_file:
+     for a in assignments:
+         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
++                a.targets[0].id == "__version__"):
++            if hasattr(ast, "Str") and isinstance(a.value, ast.Str):
++                version = a.value.s
++            elif (hasattr(ast, "Constant")
++                  and isinstance(a.value, ast.Constant)
++                  and isinstance(a.value.value, str)):
++                version = a.value.value
++assert version is not None
+
+ setup(name='html5lib',
+       version=version,
diff --git a/meta-python/recipes-devtools/python/python3-html5lib_1.1.bb b/meta-python/recipes-devtools/python/python3-html5lib_1.1.bb
index 8b32580d4a..3d7e44b87e 100644
--- a/meta-python/recipes-devtools/python/python3-html5lib_1.1.bb
+++ b/meta-python/recipes-devtools/python/python3-html5lib_1.1.bb
@@ -2,6 +2,7 @@  SUMMARY = "HTML parser based on the WHATWG HTML specifcation"
 LICENSE = "MIT"
 LIC_FILES_CHKSUM = "file://LICENSE;md5=1ba5ada9e6fead1fdc32f43c9f10ba7c"

+SRC_URI += "file://0001-setup.py-fix-version-parsing-on-Python-3.14-ast.Str-.patch"
 SRC_URI[sha256sum] = "b2e5b40261e20f354d198eae92afc10d750afb487ed5e50f9c4eaf07c184146f"

 inherit pypi setuptools3