17
0

1 Commits

Author SHA256 Message Date
Markéta Machová
cd62538c0b Add upstream htmlparser.patch to adjust for changes in CPython
(bsc#1256316)
2026-01-08 11:58:26 +01:00
5 changed files with 206 additions and 32 deletions

195
htmlparser.patch Normal file
View File

@@ -0,0 +1,195 @@
From 046ce54956a0c30120038561e53b40994d29de2c Mon Sep 17 00:00:00 2001
From: Isaac Muse <faceless.shop@gmail.com>
Date: Wed, 17 Dec 2025 19:33:55 -0700
Subject: [PATCH] Adjustments for changes in HTML parser (#285)
Fixes #284
---
docs/src/markdown/about/changelog.md | 4 ++++
soupsieve/__meta__.py | 2 +-
soupsieve/css_match.py | 4 ++--
tests/test_extra/test_soup_contains.py | 5 ++++-
tests/test_level2/test_lang.py | 5 ++++-
tests/test_level3/test_root.py | 12 ++++++++----
tests/test_level4/test_default.py | 5 ++++-
tests/test_level4/test_dir.py | 5 ++++-
tests/test_level4/test_indeterminate.py | 5 ++++-
9 files changed, 35 insertions(+), 12 deletions(-)
Index: soupsieve-2.6/soupsieve/css_match.py
===================================================================
--- soupsieve-2.6.orig/soupsieve/css_match.py
+++ soupsieve-2.6/soupsieve/css_match.py
@@ -1190,7 +1190,7 @@ class CSSMatch(_DocumentNav):
# Use cached meta language.
if found_lang is None and self.cached_meta_lang:
for cache in self.cached_meta_lang:
- if root is cache[0]:
+ if root is not None and cast(str, root) is cache[0]:
found_lang = cache[1]
# If we couldn't find a language, and the document is HTML, look to meta to determine language.
Index: soupsieve-2.6/tests/test_extra/test_soup_contains.py
===================================================================
--- soupsieve-2.6.orig/tests/test_extra/test_soup_contains.py
+++ soupsieve-2.6/tests/test_extra/test_soup_contains.py
@@ -2,6 +2,9 @@
from .. import util
import warnings
import soupsieve as sv
+from bs4 import BeautifulSoup
+
+IFRAME_TEXT = BeautifulSoup('<iframe><div></div></iframe>', 'html.parser').iframe.text == '<div></div>'
class TestSoupContains(util.TestCase):
@@ -250,7 +253,7 @@ class TestSoupContains(util.TestCase):
self.assert_selector(
markup,
'span:-soup-contains("iframe")',
- ['2'],
+ [] if IFRAME_TEXT else ['2'],
flags=util.PYHTML
)
Index: soupsieve-2.6/tests/test_level2/test_lang.py
===================================================================
--- soupsieve-2.6.orig/tests/test_level2/test_lang.py
+++ soupsieve-2.6/tests/test_level2/test_lang.py
@@ -1,5 +1,8 @@
"""Test language selector."""
from .. import util
+from bs4 import BeautifulSoup
+
+IFRAME_TEXT = BeautifulSoup('<iframe><div></div></iframe>', 'html.parser').iframe.text == '<div></div>'
class TestLang(util.TestCase):
@@ -58,7 +61,7 @@ class TestLang(util.TestCase):
self.assert_selector(
markup,
"p:lang(en)",
- ['3'],
+ [] if IFRAME_TEXT else ['3'],
flags=util.PYHTML
)
Index: soupsieve-2.6/tests/test_level3/test_root.py
===================================================================
--- soupsieve-2.6.orig/tests/test_level3/test_root.py
+++ soupsieve-2.6/tests/test_level3/test_root.py
@@ -1,6 +1,10 @@
"""Test root selectors."""
from .. import util
import soupsieve as sv
+from bs4 import BeautifulSoup
+import pytest
+
+IFRAME_TEXT = BeautifulSoup('<iframe><div></div></iframe>', 'html.parser').iframe.text == '<div></div>'
class TestRoot(util.TestCase):
@@ -65,7 +69,7 @@ class TestRoot(util.TestCase):
self.assert_selector(
self.MARKUP_IFRAME,
":root",
- ["root", "root2"],
+ ["root"] if IFRAME_TEXT else ["root", "root2"],
flags=util.PYHTML
)
@@ -85,17 +89,18 @@ class TestRoot(util.TestCase):
self.assert_selector(
self.MARKUP_IFRAME,
":root div",
- ["div", "div2", "other-div"],
+ ["div", "other-div"] if IFRAME_TEXT else ["div", "div2", "other-div"],
flags=util.PYHTML
)
self.assert_selector(
self.MARKUP_IFRAME,
":root > body > div",
- ["div", "div2", "other-div"],
+ ["div", "other-div"] if IFRAME_TEXT else ["div", "div2", "other-div"],
flags=util.PYHTML
)
+ @pytest.mark.skipif(IFRAME_TEXT, reason="Requires old Python HTML handling")
def test_iframe(self):
"""
Test that we only count `iframe` as root since the scoped element is the root.
@@ -112,7 +117,6 @@ class TestRoot(util.TestCase):
ids = [el['id'] for el in sv.select(':root > body > div', soup.iframe.html)]
self.assertEqual(sorted(ids), sorted(['div2']))
-
def test_no_root_double_tag(self):
"""Test when there is no root due to double root tags."""
Index: soupsieve-2.6/tests/test_level4/test_default.py
===================================================================
--- soupsieve-2.6.orig/tests/test_level4/test_default.py
+++ soupsieve-2.6/tests/test_level4/test_default.py
@@ -1,5 +1,8 @@
"""Test default selectors."""
from .. import util
+from bs4 import BeautifulSoup
+
+IFRAME_TEXT = BeautifulSoup('<iframe><div></div></iframe>', 'html.parser').iframe.text == '<div></div>'
class TestDefault(util.TestCase):
@@ -113,7 +116,7 @@ class TestDefault(util.TestCase):
self.assert_selector(
markup,
":default",
- ['d1', 'd3', 'd4'],
+ ['d1', 'd3'] if IFRAME_TEXT else ['d1', 'd3', 'd4'],
flags=util.PYHTML
)
Index: soupsieve-2.6/tests/test_level4/test_dir.py
===================================================================
--- soupsieve-2.6.orig/tests/test_level4/test_dir.py
+++ soupsieve-2.6/tests/test_level4/test_dir.py
@@ -1,6 +1,9 @@
"""Test direction selectors."""
from .. import util
import soupsieve as sv
+from bs4 import BeautifulSoup
+
+IFRAME_TEXT = BeautifulSoup('<iframe><div></div></iframe>', 'html.parser').iframe.text == '<div></div>'
class TestDir(util.TestCase):
@@ -169,7 +172,7 @@ class TestDir(util.TestCase):
self.assert_selector(
markup,
"div:dir(rtl)",
- ['2'],
+ [] if IFRAME_TEXT else ['2'],
flags=util.PYHTML
)
Index: soupsieve-2.6/tests/test_level4/test_indeterminate.py
===================================================================
--- soupsieve-2.6.orig/tests/test_level4/test_indeterminate.py
+++ soupsieve-2.6/tests/test_level4/test_indeterminate.py
@@ -1,5 +1,8 @@
"""Test indeterminate selectors."""
from .. import util
+from bs4 import BeautifulSoup
+
+IFRAME_TEXT = BeautifulSoup('<iframe><div></div></iframe>', 'html.parser').iframe.text == '<div></div>'
class TestIndeterminate(util.TestCase):
@@ -68,6 +71,6 @@ class TestIndeterminate(util.TestCase):
self.assert_selector(
markup,
":indeterminate",
- ['radio1', 'radio3'],
+ ['radio1'] if IFRAME_TEXT else ['radio1', 'radio3'],
flags=util.PYHTML
)

View File

@@ -1,31 +1,8 @@
------------------------------------------------------------------- -------------------------------------------------------------------
Mon Dec 29 10:10:20 UTC 2025 - Markéta Machová <mmachova@suse.com> Thu Jan 8 10:56:59 UTC 2026 - Markéta Machová <mmachova@suse.com>
- Update to 2.8.1 (bsc#1256316) - Add upstream htmlparser.patch to adjust for changes in CPython
* FIX: Changes in tests to accommodate latest Python HTML parser changes. (bsc#1256316)
-------------------------------------------------------------------
Fri Sep 26 08:45:00 UTC 2025 - John Paul Adrian Glaubitz <adrian.glaubitz@suse.com>
- Update to 2.8
* Drop support for Python 3.8.
* Add support for Python 3.14.
* Deploy with PyPI's "Trusted Publisher".
-------------------------------------------------------------------
Mon Jul 14 10:39:01 UTC 2025 - John Paul Adrian Glaubitz <adrian.glaubitz@suse.com>
- Update to 2.7
* Add :open pseudo selector.
* Add :muted pseudo selector.
* Recognize the following pseudo selectors: :autofill, :buffering,
:fullscreen, :picture-in-picture, :popover-open, :seeking, :stalled,
and :volume-locked. These selectors, while recognized, will not
match any element as they require a live environment to check
element states and browser states. This just prevents Soup Sieve
from failing when any of these selectors are specified.
* A number of existing pseudo-classes are no longer noted as experimental.
* Typing fixes.
------------------------------------------------------------------- -------------------------------------------------------------------
Wed Oct 30 19:49:47 UTC 2024 - Dirk Müller <dmueller@suse.com> Wed Oct 30 19:49:47 UTC 2024 - Dirk Müller <dmueller@suse.com>

View File

@@ -1,7 +1,7 @@
# #
# spec file for package python-soupsieve # spec file for package python-soupsieve
# #
# Copyright (c) 2025 SUSE LLC and contributors # Copyright (c) 2024 SUSE LLC
# #
# All modifications and additions to the file contributed by third parties # All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed # remain the property of their copyright owners, unless otherwise agreed
@@ -26,13 +26,15 @@
%endif %endif
%{?sle15_python_module_pythons} %{?sle15_python_module_pythons}
Name: python-soupsieve%{psuffix} Name: python-soupsieve%{psuffix}
Version: 2.8.1 Version: 2.6
Release: 0 Release: 0
Summary: A modern CSS selector implementation for BeautifulSoup Summary: A modern CSS selector implementation for BeautifulSoup
License: MIT License: MIT
Group: Development/Libraries/Python Group: Development/Libraries/Python
URL: https://github.com/facelessuser/soupsieve URL: https://github.com/facelessuser/soupsieve
Source: https://files.pythonhosted.org/packages/source/s/soupsieve/soupsieve-%{version}.tar.gz Source: https://files.pythonhosted.org/packages/source/s/soupsieve/soupsieve-%{version}.tar.gz
# PATCH-FIX-UPSTREAM https://github.com/facelessuser/soupsieve/pull/285 Adjustments for changes in HTML parser
Patch0: htmlparser.patch
BuildRequires: %{python_module hatchling} BuildRequires: %{python_module hatchling}
BuildRequires: %{python_module pip} BuildRequires: %{python_module pip}
BuildRequires: %{python_module wheel} BuildRequires: %{python_module wheel}
@@ -50,7 +52,7 @@ Soup Sieve is a CSS selector library designed to be used with Beautiful Soup 4.
It aims to provide selecting, matching, and filtering using modern CSS selectors. It aims to provide selecting, matching, and filtering using modern CSS selectors.
%prep %prep
%setup -q -n soupsieve-%{version} %autosetup -p1 -n soupsieve-%{version}
%build %build
%pyproject_wheel %pyproject_wheel

BIN
soupsieve-2.6.tar.gz LFS Normal file

Binary file not shown.

View File

@@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:4cf733bc50fa805f5df4b8ef4740fc0e0fa6218cf3006269afd3f9d6d80fd350
size 117856