diff --git a/old-libexpat.patch b/old-libexpat.patch
new file mode 100644
index 0000000..d40dd51
--- /dev/null
+++ b/old-libexpat.patch
@@ -0,0 +1,79 @@
+---
+ Lib/test/test_sax.py | 10 +++++-----
+ Lib/test/test_xml_etree.py | 17 ++++++++---------
+ 2 files changed, 13 insertions(+), 14 deletions(-)
+
+--- a/Lib/test/test_sax.py
++++ b/Lib/test/test_sax.py
+@@ -1215,10 +1215,9 @@ class ExpatReaderTest(XmlTestBase):
+
+ self.assertEqual(result.getvalue(), start + b"text")
+
++ @unittest.skipIf(pyexpat.version_info < (2, 6, 0),
++ "Reparse deferral not defined for libexpat < 2.6.0")
+ def test_flush_reparse_deferral_enabled(self):
+- if pyexpat.version_info < (2, 6, 0):
+- self.skipTest(f'Expat {pyexpat.version_info} does not support reparse deferral')
+-
+ result = BytesIO()
+ xmlgen = XMLGenerator(result)
+ parser = create_parser()
+@@ -1240,6 +1239,8 @@ class ExpatReaderTest(XmlTestBase):
+
+ self.assertEqual(result.getvalue(), start + b"")
+
++ @unittest.skipIf(pyexpat.version_info < (2, 6, 0),
++ "Reparse deferral not defined for libexpat < 2.6.0")
+ def test_flush_reparse_deferral_disabled(self):
+ result = BytesIO()
+ xmlgen = XMLGenerator(result)
+@@ -1249,8 +1250,7 @@ class ExpatReaderTest(XmlTestBase):
+ for chunk in (""):
+ parser.feed(chunk)
+
+- if pyexpat.version_info >= (2, 6, 0):
+- parser._parser.SetReparseDeferralEnabled(False)
++ parser._parser.SetReparseDeferralEnabled(False)
+
+ self.assertEqual(result.getvalue(), start) # i.e. no elements started
+ self.assertFalse(parser._parser.GetReparseDeferralEnabled())
+--- a/Lib/test/test_xml_etree.py
++++ b/Lib/test/test_xml_etree.py
+@@ -1623,11 +1623,9 @@ class XMLPullParserTest(unittest.TestCas
+ with self.assertRaises(ValueError):
+ ET.XMLPullParser(events=('start', 'end', 'bogus'))
+
++ @unittest.skipIf(pyexpat.version_info < (2, 6, 0),
++ "Reparse deferral not defined for libexpat < 2.6.0")
+ def test_flush_reparse_deferral_enabled(self):
+- if pyexpat.version_info < (2, 6, 0):
+- self.skipTest(f'Expat {pyexpat.version_info} does not '
+- 'support reparse deferral')
+-
+ parser = ET.XMLPullParser(events=('start', 'end'))
+
+ for chunk in (""):
+@@ -1648,17 +1646,18 @@ class XMLPullParserTest(unittest.TestCas
+
+ self.assert_event_tags(parser, [('end', 'doc')])
+
++ @unittest.skipIf(pyexpat.version_info < (2, 6, 0),
++ "Reparse deferral not defined for libexpat < 2.6.0")
+ def test_flush_reparse_deferral_disabled(self):
+ parser = ET.XMLPullParser(events=('start', 'end'))
+
+ for chunk in (""):
+ parser.feed(chunk)
+
+- if pyexpat.version_info >= (2, 6, 0):
+- if not ET is pyET:
+- self.skipTest(f'XMLParser.(Get|Set)ReparseDeferralEnabled '
+- 'methods not available in C')
+- parser._parser._parser.SetReparseDeferralEnabled(False)
++ if not ET is pyET:
++ self.skipTest(f'XMLParser.(Get|Set)ReparseDeferralEnabled '
++ 'methods not available in C')
++ parser._parser._parser.SetReparseDeferralEnabled(False)
+
+ self.assert_event_tags(parser, []) # i.e. no elements started
+ if ET is pyET:
diff --git a/python310.changes b/python310.changes
index 02f5165..0f27724 100644
--- a/python310.changes
+++ b/python310.changes
@@ -1,3 +1,9 @@
+-------------------------------------------------------------------
+Sun Mar 24 00:43:14 UTC 2024 - Matej Cepl
+
+- Add old-libexpat.patch making the test suite work with
+ libexpat < 2.6.0 (gh#python/cpython#117187).
+
-------------------------------------------------------------------
Fri Mar 22 21:17:25 UTC 2024 - Matej Cepl
diff --git a/python310.spec b/python310.spec
index 6c4ee62..49ce1b7 100644
--- a/python310.spec
+++ b/python310.spec
@@ -192,6 +192,9 @@ Patch20: CVE-2023-27043-email-parsing-errors.patch
# * gh#python/cpython#104221
# * gh#python/cpython#107246
Patch21: fix-sphinx-72.patch
+# PATCH-FIX-UPSTREAM old-libexpat.patch gh#python/cpython#117187 mcepl@suse.com
+# Make the test suite work with libexpat < 2.6.0
+Patch22: old-libexpat.patch
BuildRequires: autoconf-archive
BuildRequires: automake
BuildRequires: fdupes
@@ -469,6 +472,7 @@ other applications.
%patch -p1 -P 19
%patch -p1 -P 20
%patch -p1 -P 21
+%patch -p1 -P 22
# drop Autoconf version requirement
sed -i 's/^AC_PREREQ/dnl AC_PREREQ/' configure.ac