diff --git a/py313.patch b/py313.patch new file mode 100644 index 0000000..1abf719 --- /dev/null +++ b/py313.patch @@ -0,0 +1,100 @@ +From a7a2d72d9e3495ddec9dde2852fa7a932b76d0c4 Mon Sep 17 00:00:00 2001 +From: Dave Hall +Date: Sun, 11 Feb 2024 23:34:27 +0000 +Subject: [PATCH 3/5] Fixing `test_pickling` tests for Python 3.13. + +The `Handler.lock` is substituted for a `nullcontext`, keeping Python 3.13 happy. A no-op stub for `Handler.release` is added, keeping all other Python versions happy. +--- + tests/test_pickling.py | 6 ++++-- + 1 file changed, 4 insertions(+), 2 deletions(-) + +Index: loguru-0.7.2/tests/test_pickling.py +=================================================================== +--- loguru-0.7.2.orig/tests/test_pickling.py ++++ loguru-0.7.2/tests/test_pickling.py +@@ -39,11 +39,18 @@ class StreamHandler: + self.stopped = True + + ++class MockLock: ++ def __enter__(self): ++ pass ++ ++ def __exit__(self, *excinfo): ++ pass ++ ++ + class StandardHandler(logging.Handler): + def __init__(self, level): + super().__init__(level) + self.written = "" +- self.lock = None + + def emit(self, record): + self.written += record.getMessage() +@@ -51,8 +58,11 @@ class StandardHandler(logging.Handler): + def acquire(self): + pass + ++ def release(self): ++ pass ++ + def createLock(self): # noqa: N802 +- return None ++ self.lock = MockLock() + + + def format_function(record): +Index: loguru-0.7.2/loguru/_better_exceptions.py +=================================================================== +--- loguru-0.7.2.orig/loguru/_better_exceptions.py ++++ loguru-0.7.2/loguru/_better_exceptions.py +@@ -497,7 +497,7 @@ class ExceptionFormatter: + else: + yield from self._indent(introduction + "\n", group_nesting) + +- frames_lines = traceback.format_list(frames) + exception_only ++ frames_lines = self._format_list(frames) + exception_only + if self._colorize or self._backtrace or self._diagnose: + frames_lines = self._format_locations(frames_lines, has_introduction=has_introduction) + +@@ -524,5 +524,39 @@ class ExceptionFormatter: + if not is_exception_group(exc) or group_nesting == 10: + yield from self._indent("-" * 35, group_nesting + 1, prefix="+-") + ++ def _format_list(self, frames): ++ result = [] ++ last_file = None ++ last_line = None ++ last_name = None ++ count = 0 ++ for filename, lineno, name, line in frames: ++ if ( ++ last_file is not None ++ and last_file == filename ++ and last_line is not None ++ and last_line == lineno ++ and last_name is not None ++ and last_name == name ++ ): ++ count += 1 ++ else: ++ if count > 3: ++ result.append(f" [Previous line repeated {count-3} more times]\n") ++ last_file = filename ++ last_line = lineno ++ last_name = name ++ count = 0 ++ if count >= 3: ++ continue ++ row = [] ++ row.append(' File "{}", line {}, in {}\n'.format(filename, lineno, name)) ++ if line: ++ row.append(" {}\n".format(line.strip())) ++ result.append("".join(row)) ++ if count > 3: ++ result.append(f" [Previous line repeated {count-3} more times]\n") ++ return result ++ + def format_exception(self, type_, value, tb, *, from_decorator=False): + yield from self._format_exception(value, tb, is_first=True, from_decorator=from_decorator) diff --git a/py314.patch b/py314.patch new file mode 100644 index 0000000..2c2509a --- /dev/null +++ b/py314.patch @@ -0,0 +1,105 @@ +From 3a901de465b0dbb398f455dc3393d976fd0affbe Mon Sep 17 00:00:00 2001 +From: Delgan +Date: Sat, 19 Oct 2024 21:45:17 +0200 +Subject: [PATCH] Fix tests for Python 3.14 dev (#1218) + +Tests were failing for two reasons: +- "asyncio.iscoroutinefunction()" is deprecated and must be replaced +with "inspect.iscoroutinefunction()" +- it seems the "PicklingError" now displays additional context at the +end of the exception message. I changed the implemntation of the tests +so that we check the presence of the expected string regardless of the +line it appears. It wasn't strictly required for the other non-failing +tests, but I generalized the implementation for consistency and +simplification. +--- + loguru/_simple_sinks.py | 4 ++-- + tests/test_add_option_enqueue.py | 14 +++++++------- + 2 files changed, 9 insertions(+), 9 deletions(-) + +diff --git a/loguru/_simple_sinks.py b/loguru/_simple_sinks.py +index 068f1e13..658f1ad6 100644 +--- a/loguru/_simple_sinks.py ++++ b/loguru/_simple_sinks.py +@@ -1,4 +1,4 @@ +-import asyncio ++import inspect + import logging + import weakref + +@@ -10,7 +10,7 @@ def __init__(self, stream): + self._stream = stream + self._flushable = callable(getattr(stream, "flush", None)) + self._stoppable = callable(getattr(stream, "stop", None)) +- self._completable = asyncio.iscoroutinefunction(getattr(stream, "complete", None)) ++ self._completable = inspect.iscoroutinefunction(getattr(stream, "complete", None)) + + def write(self, message): + self._stream.write(message) +diff --git a/tests/test_add_option_enqueue.py b/tests/test_add_option_enqueue.py +index c367e1d7..b393f3dc 100644 +--- a/tests/test_add_option_enqueue.py ++++ b/tests/test_add_option_enqueue.py +@@ -101,7 +101,7 @@ def test_caught_exception_queue_put(writer, capsys): + assert out == "" + assert lines[0] == "--- Logging error in Loguru Handler #0 ---" + assert re.match(r"Record was: \{.*Bye bye.*\}", lines[1]) +- assert lines[-2].endswith("PicklingError: You shall not serialize me!") ++ assert "PicklingError: You shall not serialize me!" in err + assert lines[-1] == "--- End of logging error ---" + + +@@ -119,7 +119,7 @@ def test_caught_exception_queue_get(writer, capsys): + assert out == "" + assert lines[0] == "--- Logging error in Loguru Handler #0 ---" + assert lines[1] == "Record was: None" +- assert lines[-2].endswith("UnpicklingError: You shall not de-serialize me!") ++ assert "UnpicklingError: You shall not de-serialize me!" in err + assert lines[-1] == "--- End of logging error ---" + + +@@ -136,7 +136,7 @@ def test_caught_exception_sink_write(capsys): + assert out == "It's fine\nIt's fine again\n" + assert lines[0] == "--- Logging error in Loguru Handler #0 ---" + assert re.match(r"Record was: \{.*Bye bye.*\}", lines[1]) +- assert lines[-2] == "RuntimeError: You asked me to fail..." ++ assert "RuntimeError: You asked me to fail..." in err + assert lines[-1] == "--- End of logging error ---" + + +@@ -171,7 +171,7 @@ def test_not_caught_exception_queue_get(writer, capsys): + assert out == "" + assert lines[0] == "--- Logging error in Loguru Handler #0 ---" + assert lines[1] == "Record was: None" +- assert lines[-2].endswith("UnpicklingError: You shall not de-serialize me!") ++ assert "UnpicklingError: You shall not de-serialize me!" in err + assert lines[-1] == "--- End of logging error ---" + + +@@ -189,7 +189,7 @@ def test_not_caught_exception_sink_write(capsys): + assert out == "It's fine\nIt's fine again\n" + assert lines[0] == "--- Logging error in Loguru Handler #0 ---" + assert re.match(r"Record was: \{.*Bye bye.*\}", lines[1]) +- assert lines[-2] == "RuntimeError: You asked me to fail..." ++ assert "RuntimeError: You asked me to fail..." in err + assert lines[-1] == "--- End of logging error ---" + + +@@ -207,7 +207,7 @@ def test_not_caught_exception_sink_write_then_complete(capsys): + assert out == "" + assert lines[0] == "--- Logging error in Loguru Handler #0 ---" + assert re.match(r"Record was: \{.*Bye bye.*\}", lines[1]) +- assert lines[-2] == "RuntimeError: You asked me to fail..." ++ assert "RuntimeError: You asked me to fail..." in err + assert lines[-1] == "--- End of logging error ---" + + +@@ -226,7 +226,7 @@ def test_not_caught_exception_queue_get_then_complete(writer, capsys): + assert out == "" + assert lines[0] == "--- Logging error in Loguru Handler #0 ---" + assert lines[1] == "Record was: None" +- assert lines[-2].endswith("UnpicklingError: You shall not de-serialize me!") ++ assert "UnpicklingError: You shall not de-serialize me!" in err + assert lines[-1] == "--- End of logging error ---" + + diff --git a/python-loguru.changes b/python-loguru.changes index 273cb1c..373dc7d 100644 --- a/python-loguru.changes +++ b/python-loguru.changes @@ -1,3 +1,8 @@ +------------------------------------------------------------------- +Mon Oct 28 12:13:51 UTC 2024 - Dirk Müller + +- add py313.patch, py314.patch: fixes for python 3.13 and 3.14 + ------------------------------------------------------------------- Thu Oct 5 08:54:06 UTC 2023 - Dirk Müller diff --git a/python-loguru.spec b/python-loguru.spec index 081b356..f39d173 100644 --- a/python-loguru.spec +++ b/python-loguru.spec @@ -1,7 +1,7 @@ # # spec file for package python-loguru # -# Copyright (c) 2023 SUSE LLC +# Copyright (c) 2024 SUSE LLC # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -25,6 +25,9 @@ License: MIT Group: Development/Languages/Python URL: https://github.com/Delgan/loguru Source: https://files.pythonhosted.org/packages/source/l/loguru/loguru-%{version}.tar.gz +# PATCH-FIX-UPSTREAM: taken from https://github.com/Delgan/loguru/pull/1079.patch +Patch1: py313.patch +Patch2: https://github.com/Delgan/loguru/commit/3a901de465b0dbb398f455dc3393d976fd0affbe.patch#/py314.patch BuildRequires: %{python_module colorama} BuildRequires: %{python_module freezegun} BuildRequires: %{python_module pytest}