From a1fda595629a70533aecda98a67e97377f2680e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= Date: Wed, 14 Jun 2023 18:32:37 +0200 Subject: [PATCH] Avoid using the deprecated "imp" module (removed in Python 3.12) --- 07db761f9f.patch | 32 ++++++++++++++++++++++++++++++++ c6b7e621e4.patch | 24 ++++++++++++++++++++++++ python-lxml.spec | 4 ++++ 3 files changed, 60 insertions(+) create mode 100644 07db761f9f.patch create mode 100644 c6b7e621e4.patch diff --git a/07db761f9f.patch b/07db761f9f.patch new file mode 100644 index 0000000..f6070a5 --- /dev/null +++ b/07db761f9f.patch @@ -0,0 +1,32 @@ +From 07db761f9f027d1814a43686cda6fca26e37a931 Mon Sep 17 00:00:00 2001 +From: Stefan Behnel +Date: Thu, 11 May 2023 10:29:02 +0200 +Subject: [PATCH] Avoid using the deprecated "imp" module. + +Closes https://bugs.launchpad.net/lxml/+bug/2018137 +--- + src/lxml/html/tests/test_html5parser.py | 6 ++++-- + 1 file changed, 4 insertions(+), 2 deletions(-) + +diff --git a/src/lxml/html/tests/test_html5parser.py b/src/lxml/html/tests/test_html5parser.py +index 56afe98b7..bcf7f1b12 100644 +--- a/src/lxml/html/tests/test_html5parser.py ++++ b/src/lxml/html/tests/test_html5parser.py +@@ -1,5 +1,4 @@ + import os +-import imp + try: + from StringIO import StringIO + except ImportError: # python 3 +@@ -45,7 +44,10 @@ def find_module(self, fullname, path=None): + return None + + def load_module(self, fullname): +- mod = sys.modules.setdefault(fullname, imp.new_module(fullname)) ++ fake_module = object() ++ fake_module.__qualname__ = fullname ++ fake_module.__name__ = fullname.rsplit('.', 1)[-1] ++ mod = sys.modules.setdefault(fullname, fake_module) + mod.__file__, mod.__loader__, mod.__path__ = "", self, [] + mod.__dict__.update(self.mocks[fullname]) + return mod diff --git a/c6b7e621e4.patch b/c6b7e621e4.patch new file mode 100644 index 0000000..fbdb61d --- /dev/null +++ b/c6b7e621e4.patch @@ -0,0 +1,24 @@ +From c6b7e621e4696c02bf8f6ea423ffbbf2109748ab Mon Sep 17 00:00:00 2001 +From: Stefan Behnel +Date: Thu, 11 May 2023 10:30:15 +0200 +Subject: [PATCH] Avoid using the deprecated "imp" module. + +Closes https://bugs.launchpad.net/lxml/+bug/2018137 +--- + src/lxml/html/tests/test_html5parser.py | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/src/lxml/html/tests/test_html5parser.py b/src/lxml/html/tests/test_html5parser.py +index bcf7f1b12..57878a5e3 100644 +--- a/src/lxml/html/tests/test_html5parser.py ++++ b/src/lxml/html/tests/test_html5parser.py +@@ -44,7 +44,8 @@ def find_module(self, fullname, path=None): + return None + + def load_module(self, fullname): +- fake_module = object() ++ class Cls: pass ++ fake_module = Cls() + fake_module.__qualname__ = fullname + fake_module.__name__ = fullname.rsplit('.', 1)[-1] + mod = sys.modules.setdefault(fullname, fake_module) diff --git a/python-lxml.spec b/python-lxml.spec index 2cdd85e..fb979e8 100644 --- a/python-lxml.spec +++ b/python-lxml.spec @@ -20,6 +20,10 @@ Source1: get-lxml-source.sh # Upstream issue: https://bugs.launchpad.net/lxml/+bug/2016939 Patch: Skip-failing-test-test_html_prefix_nsmap.patch +# Avoid using the deprecated "imp" module (removed in Python 3.12) +Patch: https://github.com/lxml/lxml/commit/07db761f9f.patch +Patch: https://github.com/lxml/lxml/commit/c6b7e621e4.patch + BuildRequires: gcc BuildRequires: libxml2-devel BuildRequires: libxslt-devel