Control: tags -1 + patch
Hi!
I ran into this issue while rebuilding the python related packages
against the Python 3.15rc1 version [1].
The root cause has already been fixed upstream with commit b501be1 [2].
I applied the upstream fix in the sandbox [3] to be able to build the
packages that depend on python-oslo.log, and it built successfully.
Happy hacking,
[1]:
https://debusine.debian.net/debian/r-python-python3.15/work-request/1177640/
[2]:
https://github.com/openstack/oslo.log/commit/b501be134454d5a0fdb91ce30bea384b0f3db7d0
[3]: https://debusine.debian.net/debian/r-python-python3.15/
--
"If you optimize everything, you will always be unhappy."
-- Donald Knuth
Saludos /\/\ /\ >< `/
From b501be134454d5a0fdb91ce30bea384b0f3db7d0 Mon Sep 17 00:00:00 2001
From: Thomas Goirand <[email protected]>
Date: Fri, 21 Aug 2026 17:45:11 +0200
Subject: [PATCH] Address Python 3.13 issue
Currently, building without this patch in Python 3.13 and 3.14 lead to:
testtools.testresult.real._StringException: Traceback (most recent call last):
File "/usr/lib/python3.13/unittest/mock.py", line 1432, in patched
return func(*newargs, **newkeywargs)
File "/build/python-oslo.log-0fVnL2/python-oslo.log-8.3.0/oslo_log/tests/unit/test_log.py", line 184, in test_rotate_log
self.assertEqual(self.log_handlers[0], handler_mock.return_value)
~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/testtools/testcase.py", line 438, in assertEqual
self.assertThat(observed, matcher, message)
~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/testtools/testcase.py", line 587, in assertThat
raise mismatch_error
testtools.matchers._impl.MismatchError: !=:
reference = <StreamHandler <stdout> (NOTSET)>
actual = <MagicMock name='RotatingFileHandler()' id='140703819264896'>
3 tests are affected with this issue. This is because the cached handler
reference from setUp() becomes stale after _setup_logging_from_conf()
runs with active mocks. This patch fixes this by fetching a new log handler.
In addition, we fix some typing errors that are highlighted by recent
mypy versions.
Signed-off-by: Thomas Goirand <[email protected]>
Co-authored-by: Takashi Kajinami <[email protected]>
Assisted-By: Infomaniak Euria
Change-Id: I655b0f7c9e64206c63a32b11cb9da2cfe18a8320
---
oslo_log/tests/unit/test_log.py | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
Index: python-oslo.log/oslo_log/tests/unit/test_log.py
===================================================================
--- python-oslo.log.orig/oslo_log/tests/unit/test_log.py
+++ python-oslo.log/oslo_log/tests/unit/test_log.py
@@ -163,7 +163,9 @@ class LoggerTestCase(test_base.BaseTestC
interval=interval,
backupCount=backup_count,
)
- self.assertEqual(self.log_handlers[0], handler_mock.return_value)
+ self.assertEqual(
+ log.getLogger(None).logger.handlers[0], handler_mock.return_value
+ )
@mock.patch('logging.handlers.RotatingFileHandler')
@mock.patch('oslo_log.log._get_log_file_path', return_value='test.conf')
@@ -181,7 +183,9 @@ class LoggerTestCase(test_base.BaseTestC
handler_mock.assert_called_once_with(
path_mock.return_value, maxBytes=maxBytes, backupCount=backup_count
)
- self.assertEqual(self.log_handlers[0], handler_mock.return_value)
+ self.assertEqual(
+ log.getLogger(None).logger.handlers[0], handler_mock.return_value
+ )
class BaseTestCase(test_base.BaseTestCase):