From 55a285408310bc447080d39da6fe068b72a9125d Mon Sep 17 00:00:00 2001 From: Jingyun Hua <huajingyun@loongson.cn> Date: Tue, 3 Sep 2024 13:03:28 +0000 Subject: [PATCH] community/py3-beautifulsoup4: fix build error Patch backport: https://git.launchpad.net/beautifulsoup/commit/?id=9786a62726de5a8caba10021c4d4a58c8a3e9e3f --- community/py3-beautifulsoup4/APKBUILD | 6 +- ...tests-work-whether-tests-are-run-und.patch | 110 ++++++++++++++++++ 2 files changed, 114 insertions(+), 2 deletions(-) create mode 100644 community/py3-beautifulsoup4/Changes-to-make-tests-work-whether-tests-are-run-und.patch diff --git a/community/py3-beautifulsoup4/APKBUILD b/community/py3-beautifulsoup4/APKBUILD index cd08895feab1..7919e7325e1d 100644 --- a/community/py3-beautifulsoup4/APKBUILD +++ b/community/py3-beautifulsoup4/APKBUILD @@ -4,7 +4,7 @@ pkgname=py3-beautifulsoup4 _pkgname=beautifulsoup4 pkgver=4.12.3 -pkgrel=2 +pkgrel=3 pkgdesc="A Python HTML/XML parser" url="https://www.crummy.com/software/BeautifulSoup/index.html" arch="noarch" @@ -16,7 +16,8 @@ makedepends=" " checkdepends="py3-pytest" subpackages="$pkgname-pyc" -source="https://files.pythonhosted.org/packages/source/b/beautifulsoup4/beautifulsoup4-$pkgver.tar.gz" +source="https://files.pythonhosted.org/packages/source/b/beautifulsoup4/beautifulsoup4-$pkgver.tar.gz + Changes-to-make-tests-work-whether-tests-are-run-und.patch" builddir="$srcdir/$_pkgname-$pkgver" replaces="py-beautifulsoup4" # Backwards compatibility @@ -40,4 +41,5 @@ package() { sha512sums=" b5b6cc9f64a97fa52b9a2ee1265aa215db476e705d3d79e49301de7e8d36c56c96924cb440eec0715f7ec75c5ddf4c1ade9d6cef7cdc9bf9e37125ac6eb50837 beautifulsoup4-4.12.3.tar.gz +3c16c547b995e1172c34473907d5f2f400d2828e1486106c13a98bdeb59df4a0004750365da3ffff0bc390e640b7cea7c85945e5872381acd72a6ca141987779 Changes-to-make-tests-work-whether-tests-are-run-und.patch " diff --git a/community/py3-beautifulsoup4/Changes-to-make-tests-work-whether-tests-are-run-und.patch b/community/py3-beautifulsoup4/Changes-to-make-tests-work-whether-tests-are-run-und.patch new file mode 100644 index 000000000000..f832051407b7 --- /dev/null +++ b/community/py3-beautifulsoup4/Changes-to-make-tests-work-whether-tests-are-run-und.patch @@ -0,0 +1,110 @@ +From 9786a62726de5a8caba10021c4d4a58c8a3e9e3f Mon Sep 17 00:00:00 2001 +From: Leonard Richardson <leonardr@segfault.org> +Date: Wed, 21 Aug 2024 20:18:33 -0400 +Subject: [PATCH] * Changes to make tests work whether tests are run under + soupsieve 2.6 or an earlier version. Based on a patch by Stefano Rivera. + +* Removed the strip_cdata argument to lxml's HTMLParser + constructor, which never did anything and is deprecated as of lxml + 5.3.0. Patch by Stefano Rivera. [bug=2076897] +--- + CHANGELOG | 9 +++++++++ + bs4/builder/_lxml.py | 4 ++-- + bs4/tests/test_css.py | 13 +++++++++++-- + tox.ini | 3 ++- + 4 files changed, 24 insertions(+), 5 deletions(-) + +diff --git a/CHANGELOG b/CHANGELOG +index 2701446..243caf0 100644 +--- a/CHANGELOG ++++ b/CHANGELOG +@@ -1,3 +1,12 @@ ++= Unreleased ++ ++* Changes to make tests work whether tests are run under soupsieve 2.6 ++ or an earlier version. Based on a patch by Stefano Rivera. ++ ++* Removed the strip_cdata argument to lxml's HTMLParser ++ constructor, which never did anything and is deprecated as of lxml ++ 5.3.0. Patch by Stefano Rivera. [bug=2076897] ++ + = 4.12.3 (20240117) + + * The Beautiful Soup documentation now has a Spanish translation, thanks +diff --git a/bs4/builder/_lxml.py b/bs4/builder/_lxml.py +index 4f7cf74..502a776 100644 +--- a/bs4/builder/_lxml.py ++++ b/bs4/builder/_lxml.py +@@ -108,7 +108,7 @@ class LXMLTreeBuilderForXML(TreeBuilder): + if self._default_parser is not None: + return self._default_parser + return etree.XMLParser( +- target=self, strip_cdata=False, recover=True, encoding=encoding) ++ target=self, recover=True, encoding=encoding) + + def parser_for(self, encoding): + """Instantiate an appropriate parser for the given encoding. +@@ -122,7 +122,7 @@ class LXMLTreeBuilderForXML(TreeBuilder): + if isinstance(parser, Callable): + # Instantiate the parser with default arguments + parser = parser( +- target=self, strip_cdata=False, recover=True, encoding=encoding ++ target=self, recover=True, encoding=encoding + ) + return parser + +diff --git a/bs4/tests/test_css.py b/bs4/tests/test_css.py +index 359dbcd..3c2318b 100644 +--- a/bs4/tests/test_css.py ++++ b/bs4/tests/test_css.py +@@ -8,14 +8,23 @@ from bs4 import ( + ResultSet, + ) + ++from packaging.version import Version ++ + from . import ( + SoupTest, + SOUP_SIEVE_PRESENT, + ) + + if SOUP_SIEVE_PRESENT: +- from soupsieve import SelectorSyntaxError ++ from soupsieve import __version__, SelectorSyntaxError + ++ # Some behavior changes in soupsieve 2.6 that affects one of our ++ # tests. For the test to run under all versions of Python ++ # supported by Beautiful Soup (which includes versions of Python ++ # not supported by soupsieve 2.6) we need to check both behaviors. ++ SOUPSIEVE_EXCEPTION_ON_UNSUPPORTED_PSEUDOCLASS = SelectorSyntaxError ++ if Version(__version__) < Version("2.6"): ++ SOUPSIEVE_EXCEPTION_ON_UNSUPPORTED_PSEUDOCLASS = NotImplementedError + + @pytest.mark.skipif(not SOUP_SIEVE_PRESENT, reason="Soup Sieve not installed") + class TestCSSSelectors(SoupTest): +@@ -332,7 +341,7 @@ class TestCSSSelectors(SoupTest): + assert "yes" == chosen.string + + def test_unsupported_pseudoclass(self): +- with pytest.raises(NotImplementedError): ++ with pytest.raises(SOUPSIEVE_EXCEPTION_ON_UNSUPPORTED_PSEUDOCLASS): + self.soup.select("a:no-such-pseudoclass") + + with pytest.raises(SelectorSyntaxError): +diff --git a/tox.ini b/tox.ini +index fc55fca..79f15a5 100644 +--- a/tox.ini ++++ b/tox.ini +@@ -10,7 +10,8 @@ wheel_build_env = .pkg + description = run the tests with all dependencies installed + deps = lxml + html5lib +- soupsieve>=1.2 ++ packaging ++ soupsieve>=2.6 + pytest>=6 + commands = pytest {tty:--color=yes} {posargs} + +-- +2.46.0 + -- GitLab