commit:     b826c24e1ff0fd6926525e6345dfb907c363da7a
Author:     Petr Vaněk <arkamar <AT> atlas <DOT> cz>
AuthorDate: Wed Mar  1 15:56:57 2023 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Tue Mar  7 09:17:40 2023 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=b826c24e

dev-python/loguru: enable py3.11

It is necessary to apply two patches in order to fix test. One applies
cleanly and it is downloaded with SRC_URI but it was needed to cut out
only relevant parts with the second one, otherwise it fails to apply and
it is stored in FILESDIR.

Test didn't work in tmpfs, nor xfs but they pass in ext4 (mounted
via loop device from file stored in tmpfs)

Closes: https://bugs.gentoo.org/896798
Signed-off-by: Petr Vaněk <arkamar <AT> atlas.cz>
Closes: https://github.com/gentoo/gentoo/pull/29974
Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>

 dev-python/loguru/Manifest                    |  1 +
 dev-python/loguru/files/0.6.0-py311-fix.patch | 68 +++++++++++++++++++++++++++
 dev-python/loguru/loguru-0.6.0-r1.ebuild      |  8 +++-
 3 files changed, 75 insertions(+), 2 deletions(-)

diff --git a/dev-python/loguru/Manifest b/dev-python/loguru/Manifest
index 90c60f6e77ba..208a6357826c 100644
--- a/dev-python/loguru/Manifest
+++ b/dev-python/loguru/Manifest
@@ -1,2 +1,3 @@
+DIST loguru-0.6.0-py311-repr-tests.patch 4251 BLAKE2B 
21891ede1845387f915d3889dfb077af78e88909ce7efe25cd194516dab465738d3c398195552e8a8a54913804df1bc74bf95c4e12494b8e7f628894d0c12177
 SHA512 
e1da062ba49e53ecfedc044d59f969797bd1dec99c64e42d5420af6cba80db95d242ed7d155b180e84dacba4bd56298fd5a4cae784ef4eec1709905da1a1c93f
 DIST loguru-0.6.0.gh.tar.gz 417660 BLAKE2B 
a7b7d95ffcf652769503db3423768ff85a4fa4898f0e2b155d96ce0c42fa7f24255f9dc49ba62e8a4f19bb3b7cc8b374580fe0965c9683b14d9bcea9866e71a5
 SHA512 
6ca7087cde3b4ce11255e31af988e5e118a7ebfbb338b97ebd6e7e4af716f0301c0180a59b18c879fd799c25802b428411b868290b7593212f06d70bcbd6a9ca
 DIST loguru-0.6.0.tar.gz 417660 BLAKE2B 
a7b7d95ffcf652769503db3423768ff85a4fa4898f0e2b155d96ce0c42fa7f24255f9dc49ba62e8a4f19bb3b7cc8b374580fe0965c9683b14d9bcea9866e71a5
 SHA512 
6ca7087cde3b4ce11255e31af988e5e118a7ebfbb338b97ebd6e7e4af716f0301c0180a59b18c879fd799c25802b428411b868290b7593212f06d70bcbd6a9ca

diff --git a/dev-python/loguru/files/0.6.0-py311-fix.patch 
b/dev-python/loguru/files/0.6.0-py311-fix.patch
new file mode 100644
index 000000000000..a7d29b911fac
--- /dev/null
+++ b/dev-python/loguru/files/0.6.0-py311-fix.patch
@@ -0,0 +1,68 @@
+Fix failing tests on Python 3.11 (#654)
+
+Issue: https://github.com/Delgan/loguru/issues/654
+Commit: 
https://github.com/Delgan/loguru/commit/5b77724ca75aa8f4b1c8866e0b786c3cbe30ca99
+
+diff --git a/tests/test_filesink_rotation.py b/tests/test_filesink_rotation.py
+index bdf75a3..fb80b69 100644
+--- a/tests/test_filesink_rotation.py
++++ b/tests/test_filesink_rotation.py
+@@ -49,8 +49,8 @@ def monkeypatch_filesystem(monkeypatch):
+                     return self._timestamp
+                 return getattr(self._wrapped, name)
+ 
+-        def patched_stat(filepath):
+-            stat = __stat__(filepath)
++        def patched_stat(filepath, *args, **kwargs):
++            stat = __stat__(filepath, *args, **kwargs)
+             wrapped = StatWrapper(stat, 
filesystem.get(os.path.abspath(filepath)))
+             return wrapped
+ 
+diff --git a/tests/test_interception.py b/tests/test_interception.py
+index a05802a..2f570b9 100644
+--- a/tests/test_interception.py
++++ b/tests/test_interception.py
+@@ -1,4 +1,5 @@
+ import logging
++import sys
+ 
+ from loguru import logger
+ 
+@@ -7,15 +8,15 @@ from .conftest import make_logging_logger
+ 
+ class InterceptHandler(logging.Handler):
+     def emit(self, record):
+-        # Get corresponding Loguru level if it exists
++        # Get corresponding Loguru level if it exists.
+         try:
+             level = logger.level(record.levelname).name
+         except ValueError:
+             level = record.levelno
+ 
+-        # Find caller from where originated the logged message
+-        frame, depth = logging.currentframe(), 2
+-        while frame.f_code.co_filename == logging.__file__:
++        # Find caller from where originated the logged message.
++        frame, depth = sys._getframe(6), 6
++        while frame and frame.f_code.co_filename == logging.__file__:
+             frame = frame.f_back
+             depth += 1
+ 
+@@ -30,7 +31,7 @@ def test_formatting(writer):
+ 
+     expected = (
+         "tests.test_interception - test_interception.py - test_formatting - 
DEBUG - "
+-        "10 - 38 - test_interception - This is the message\n"
++        "10 - 39 - test_interception - This is the message\n"
+     )
+ 
+     with make_logging_logger("tests", InterceptHandler()) as logging_logger:
+@@ -157,4 +158,4 @@ def test_using_logging_function(writer):
+         logging.warning("ABC")
+ 
+     result = writer.read()
+-    assert result == "test_using_logging_function 157 test_interception 
test_interception.py ABC\n"
++    assert result == "test_using_logging_function 158 test_interception 
test_interception.py ABC\n"
+-- 
+2.39.2
+

diff --git a/dev-python/loguru/loguru-0.6.0-r1.ebuild 
b/dev-python/loguru/loguru-0.6.0-r1.ebuild
index 6c59eba2c805..d4b4aeee1ce2 100644
--- a/dev-python/loguru/loguru-0.6.0-r1.ebuild
+++ b/dev-python/loguru/loguru-0.6.0-r1.ebuild
@@ -4,7 +4,7 @@
 EAPI=8
 
 DISTUTILS_USE_PEP517=setuptools
-PYTHON_COMPAT=( python3_{9..10} )
+PYTHON_COMPAT=( python3_{9..11} )
 
 inherit distutils-r1
 
@@ -16,6 +16,8 @@ HOMEPAGE="
 SRC_URI="
        https://github.com/Delgan/loguru/archive/${PV}.tar.gz
                -> ${P}.gh.tar.gz
+       
https://github.com/Delgan/loguru/commit/4fe21f66991abeb1905e24c3bc3c634543d959a2.patch
+               -> ${P}-py311-repr-tests.patch
 "
 
 LICENSE="MIT"
@@ -29,7 +31,9 @@ BDEPEND="
 "
 
 PATCHES=(
-       "${FILESDIR}/0.6.0-typos.patch"
+       "${FILESDIR}/${PV}-typos.patch"
+       "${FILESDIR}/${PV}-py311-fix.patch"
+       "${DISTDIR}/${P}-py311-repr-tests.patch"
 )
 
 # filesystem buffering tests may fail

Reply via email to