commit:     17d621befbd64f7696978b3bdef56e970bcc2a15
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Tue May 14 09:43:37 2024 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Tue May 14 09:54:21 2024 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=17d621be

dev-python/jinja: Enable py3.13

Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>

 dev-python/jinja/files/jinja-3.1.4-py313.patch | 67 ++++++++++++++++++++++++++
 dev-python/jinja/jinja-3.1.4.ebuild            |  7 ++-
 2 files changed, 73 insertions(+), 1 deletion(-)

diff --git a/dev-python/jinja/files/jinja-3.1.4-py313.patch 
b/dev-python/jinja/files/jinja-3.1.4-py313.patch
new file mode 100644
index 000000000000..b68091e5397a
--- /dev/null
+++ b/dev-python/jinja/files/jinja-3.1.4-py313.patch
@@ -0,0 +1,67 @@
+From 679af7f816ced8941ed5cf9b151a0cac543d0336 Mon Sep 17 00:00:00 2001
+From: Thomas Grainger <[email protected]>
+Date: Mon, 13 May 2024 18:02:35 +0100
+Subject: [PATCH] fix test_package_zip_list on 3.13
+
+---
+ src/jinja2/loaders.py | 32 ++++++++++++++++++++++++++------
+ tests/test_loader.py  |  2 +-
+ 2 files changed, 27 insertions(+), 7 deletions(-)
+
+diff --git a/src/jinja2/loaders.py b/src/jinja2/loaders.py
+index 9eaf647ba..8c2c86cd0 100644
+--- a/src/jinja2/loaders.py
++++ b/src/jinja2/loaders.py
+@@ -238,6 +238,30 @@ def list_templates(self) -> t.List[str]:
+         return sorted(found)
+ 
+ 
++if sys.version_info >= (3, 13):
++
++    def _get_zipimporter_files(z: t.Any) -> t.Dict[str, object]:
++        try:
++            get_files = z._get_files
++        except AttributeError as e:
++            raise TypeError(
++                "This zip import does not have the required"
++                " metadata to list templates."
++            ) from e
++        return get_files()
++else:
++
++    def _get_zipimporter_files(z: t.Any) -> t.Dict[str, object]:
++        try:
++            files = z._files
++        except AttributeError as e:
++            raise TypeError(
++                "This zip import does not have the required"
++                " metadata to list templates."
++            ) from e
++        return files  # type: ignore[no-any-return]
++
++
+ class PackageLoader(BaseLoader):
+     """Load templates from a directory in a Python package.
+ 
+@@ -382,11 +406,7 @@ def list_templates(self) -> t.List[str]:
+                     for name in filenames
+                 )
+         else:
+-            if not hasattr(self._loader, "_files"):
+-                raise TypeError(
+-                    "This zip import does not have the required"
+-                    " metadata to list templates."
+-                )
++            files = _get_zipimporter_files(self._loader)
+ 
+             # Package is a zip file.
+             prefix = (
+@@ -395,7 +415,7 @@ def list_templates(self) -> t.List[str]:
+             )
+             offset = len(prefix)
+ 
+-            for name in self._loader._files.keys():
++            for name in files:
+                 # Find names under the templates directory that aren't 
directories.
+                 if name.startswith(prefix) and name[-1] != os.path.sep:
+                     results.append(name[offset:].replace(os.path.sep, "/"))

diff --git a/dev-python/jinja/jinja-3.1.4.ebuild 
b/dev-python/jinja/jinja-3.1.4.ebuild
index a11efb7ba171..6f74d056289b 100644
--- a/dev-python/jinja/jinja-3.1.4.ebuild
+++ b/dev-python/jinja/jinja-3.1.4.ebuild
@@ -5,7 +5,7 @@ EAPI=8
 
 DISTUTILS_USE_PEP517=flit
 PYPI_PN=jinja2
-PYTHON_COMPAT=( python3_{10..12} pypy3 )
+PYTHON_COMPAT=( python3_{10..13} pypy3 )
 PYTHON_REQ_USE="threads(+)"
 
 inherit distutils-r1 pypi
@@ -33,6 +33,11 @@ distutils_enable_tests pytest
 # XXX: handle Babel better?
 
 src_prepare() {
+       local PATCHES=(
+               # https://github.com/pallets/jinja/pull/1979
+               "${FILESDIR}/${P}-py313.patch"
+       )
+
        # avoid unnecessary dep on extra sphinxcontrib modules
        sed -i '/sphinxcontrib.log_cabinet/ d' docs/conf.py || die
 

Reply via email to