diff options
author | Markus Heiser <markus.heiser@darmarit.de> | 2024-04-08 08:50:14 +0200 |
---|---|---|
committer | Markus Heiser <markus.heiser@darmarIT.de> | 2024-04-08 10:55:23 +0200 |
commit | bd6ff29f8f199c9835bfc5090ea5c4eba25cf3f1 (patch) | |
tree | 749e98ad564662d6a5393ab55550d5fbf2593101 | |
parent | 26a92c1a8d0420c0254653f40d107a877b882a17 (diff) | |
download | searxng-bd6ff29f8f199c9835bfc5090ea5c4eba25cf3f1.tar.gz searxng-bd6ff29f8f199c9835bfc5090ea5c4eba25cf3f1.zip |
[fix] remove usage of no longer existing names from lxml
In lxml 5.1.1 the private name `_ElementStringResult` in module `lxml.etree`
does no longer exists.
This code was written nearly a decade ago, its no longer clear what the
intention `_ElementStringResult` and `_ElementUnicodeResult` had been. It can be
assumed that these classes will no longer occur.
Closes: https://github.com/searxng/searxng/issues/3368
Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
-rw-r--r-- | searx/utils.py | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/searx/utils.py b/searx/utils.py index cd0e20260..f50618ea2 100644 --- a/searx/utils.py +++ b/searx/utils.py @@ -18,7 +18,7 @@ from urllib.parse import urljoin, urlparse from markdown_it import MarkdownIt from lxml import html -from lxml.etree import ElementBase, XPath, XPathError, XPathSyntaxError, _ElementStringResult, _ElementUnicodeResult +from lxml.etree import ElementBase, XPath, XPathError, XPathSyntaxError from searx import settings from searx.data import USER_AGENTS, data_dir @@ -217,7 +217,7 @@ def extract_text(xpath_results, allow_none: bool = False) -> Optional[str]: text: str = html.tostring(xpath_results, encoding='unicode', method='text', with_tail=False) text = text.strip().replace('\n', ' ') return ' '.join(text.split()) - if isinstance(xpath_results, (_ElementStringResult, _ElementUnicodeResult, str, Number, bool)): + if isinstance(xpath_results, (str, Number, bool)): return str(xpath_results) if xpath_results is None and allow_none: return None |