public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
* [rpms/python-twisted] rawhide: Fix compatibility with Python 3.15
@ 2026-06-03  9:55 Lumir Balhar
  0 siblings, 0 replies; only message in thread
From: Lumir Balhar @ 2026-06-03  9:55 UTC (permalink / raw)
  To: git-commits

A new commit has been pushed.

Repo   : rpms/python-twisted
Branch : rawhide
Commit : e22482a304fbc7a55b4120718dc0bfc59cdc9cd9
Author : Lumir Balhar <lbalhar@redhat.com>
Date   : 2026-04-01T14:00:33+02:00
Stats  : +126/-0 in 2 file(s)
URL    : https://src.fedoraproject.org/rpms/python-twisted/c/e22482a304fbc7a55b4120718dc0bfc59cdc9cd9?branch=rawhide

Log:
Fix compatibility with Python 3.15

---
diff --git a/0004-Fix-Python-3.15-compatibility-issues.patch b/0004-Fix-Python-3.15-compatibility-issues.patch
new file mode 100644
index 0000000..08e5e4d
--- /dev/null
+++ b/0004-Fix-Python-3.15-compatibility-issues.patch
@@ -0,0 +1,123 @@
+From c18ad3ebbd778545acc1104ecdc78137aa5534f1 Mon Sep 17 00:00:00 2001
+From: Lumir Balhar <lbalhar@redhat.com>
+Date: Wed, 1 Apr 2026 11:46:56 +0200
+Subject: [PATCH] Fix Python 3.15 compatibility issues
+
+- Replace deprecated SourceFileLoader.load_module() with exec_module()
+- Add addSubTest() method to _AdaptedReporter for Python 3.15 doctest support
+- Update test expectations for Python 3.15 doctest changes:
+  - Different success/failure counts
+  - Changed error output format
+---
+ src/twisted/trial/reporter.py           | 13 +++++++++++++
+ src/twisted/trial/runner.py             |  6 +++++-
+ src/twisted/trial/test/test_doctest.py  |  9 +++++++--
+ src/twisted/trial/test/test_reporter.py | 18 +++++++++++++-----
+ 4 files changed, 38 insertions(+), 8 deletions(-)
+
+diff --git a/src/twisted/trial/reporter.py b/src/twisted/trial/reporter.py
+index 2034a83..a1b91e9 100644
+--- a/src/twisted/trial/reporter.py
++++ b/src/twisted/trial/reporter.py
+@@ -381,6 +381,19 @@ class _AdaptedReporter(TestResultDecorator):
+         """
+         return self._originalReporter.stopTest(self.testAdapter(test))
+ 
++    def addSubTest(self, test, subtest, outcome):
++        """
++        See L{unittest.TestResult.addSubTest}.
++
++        Called by the doctest runner in Python 3.15+ when reporting sub-test results.
++        """
++        test = self.testAdapter(test)
++        if hasattr(self._originalReporter, "addSubTest"):
++            return self._originalReporter.addSubTest(test, subtest, outcome)
++        # If the underlying reporter doesn't support subtests, treat as error/success
++        if outcome is not None:
++            return self._originalReporter.addError(test, outcome)
++
+ 
+ @implementer(itrial.IReporter)
+ class Reporter(TestResult):
+diff --git a/src/twisted/trial/runner.py b/src/twisted/trial/runner.py
+index ffc554e..c7ba6f9 100644
+--- a/src/twisted/trial/runner.py
++++ b/src/twisted/trial/runner.py
+@@ -760,7 +760,11 @@ class TestLoader:
+         """
+         name = reflect.filenameToModuleName(fileName)
+         try:
+-            module = SourceFileLoader(name, fileName).load_module()
++            loader = SourceFileLoader(name, fileName)
++            spec = importlib.util.spec_from_loader(name, loader)
++            module = importlib.util.module_from_spec(spec)
++            sys.modules[name] = module
++            spec.loader.exec_module(module)
+             return self.loadAnything(module, recurse=recurse)
+         except OSError:
+             raise ValueError(f"{fileName} is not a Python file.")
+diff --git a/src/twisted/trial/test/test_doctest.py b/src/twisted/trial/test/test_doctest.py
+index 05d57d4..5f6a1c1 100644
+--- a/src/twisted/trial/test/test_doctest.py
++++ b/src/twisted/trial/test/test_doctest.py
+@@ -4,6 +4,7 @@
+ """
+ Test Twisted's doctest support.
+ """
++import sys
+ import unittest as pyunit
+ 
+ from twisted.trial import itrial, reporter, runner, unittest
+@@ -40,8 +41,12 @@ class RunnersTests(unittest.SynchronousTestCase):
+         """
+         result = reporter.TestResult()
+         suite.run(result)
+-        self.assertEqual(5, result.successes)
+-        self.assertEqual(2, len(result.failures))
++        # Python 3.15+ counts doctest examples differently, resulting in more successes
++        # and also consolidates some failures
++        expected_successes = 7 if sys.version_info >= (3, 15) else 5
++        expected_failures = 1 if sys.version_info >= (3, 15) else 2
++        self.assertEqual(expected_successes, result.successes)
++        self.assertEqual(expected_failures, len(result.failures))
+ 
+     def test_expectedResults(self, count: int = 1) -> None:
+         """
+diff --git a/src/twisted/trial/test/test_reporter.py b/src/twisted/trial/test/test_reporter.py
+index 76172e7..0b47f24 100644
+--- a/src/twisted/trial/test/test_reporter.py
++++ b/src/twisted/trial/test/test_reporter.py
+@@ -200,17 +200,25 @@ class ErrorReportingTests(StringTest):
+         stream with a I{FAIL} or I{ERROR} tag along with a summary of what
+         problem was encountered and the ID of the test.
+         """
++        import sys
+         from twisted.trial.test import erroneous
+ 
+         suite = unittest.decorate(self.loader.loadDoctests(erroneous), itrial.ITestCase)
+         output = self.getOutput(suite)
+         path = "twisted.trial.test.erroneous.unexpectedException"
+-        for substring in ["1/0", "ZeroDivisionError", "Exception raised:", path]:
++        # Python 3.15+ changed doctest error output format
++        if sys.version_info >= (3, 15):
++            substrings = ["1/0", "ZeroDivisionError", path]
++        else:
++            substrings = ["1/0", "ZeroDivisionError", "Exception raised:", path]
++        for substring in substrings:
+             self.assertSubstring(substring, output)
+-        self.assertTrue(
+-            re.search("Fail(ed|ure in) example:", output),
+-            "Couldn't match 'Failure in example: ' " "or 'Failed example: '",
+-        )
++        # Python 3.15+ no longer uses "Failed example:" format
++        if sys.version_info < (3, 15):
++            self.assertTrue(
++                re.search("Fail(ed|ure in) example:", output),
++                "Couldn't match 'Failure in example: ' " "or 'Failed example: '",
++            )
+         expect = [self.doubleSeparator, re.compile(r"\[(ERROR|FAIL)\]")]
+         self.stringComparison(expect, output.splitlines())
+ 
+-- 
+2.53.0
+

diff --git a/python-twisted.spec b/python-twisted.spec
index 5c3d27a..7f53bff 100644
--- a/python-twisted.spec
+++ b/python-twisted.spec
@@ -22,6 +22,9 @@ Patch1:         0001-Fix-asyncio-get_event_loop-for-Python-3-14.patch
 Patch2:         0002-Fix-web-client-urljoin-for-Python-3-14.patch
 # https://github.com/twisted/twisted/pull/12551
 Patch3:         0003-Fix-tests-for-Python-3-14-2.patch
+# Fix Python 3.15 compatibility issues
+# https://github.com/twisted/twisted/pull/12602
+Patch4:         0004-Fix-Python-3.15-compatibility-issues.patch
 
 BuildArch:      noarch
 

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2026-06-03  9:55 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-06-03  9:55 [rpms/python-twisted] rawhide: Fix compatibility with Python 3.15 Lumir Balhar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox