diff options
-rw-r--r-- | meta/recipes-devtools/python/python3-jinja2/fix-3.13.patch | 87 | ||||
-rw-r--r-- | meta/recipes-devtools/python/python3-jinja2_3.1.4.bb | 1 |
2 files changed, 88 insertions, 0 deletions
diff --git a/meta/recipes-devtools/python/python3-jinja2/fix-3.13.patch b/meta/recipes-devtools/python/python3-jinja2/fix-3.13.patch new file mode 100644 index 0000000000..34ecd15176 --- /dev/null +++ b/meta/recipes-devtools/python/python3-jinja2/fix-3.13.patch | |||
@@ -0,0 +1,87 @@ | |||
1 | From cf6ba7732b49ab4637aa747186cf1d1572688584 Mon Sep 17 00:00:00 2001 | ||
2 | From: Thomas Grainger <tagrain@gmail.com> | ||
3 | Date: Mon, 13 May 2024 18:02:35 +0100 | ||
4 | Subject: [PATCH] fix test_package_zip_list on 3.13 | ||
5 | |||
6 | Upstream-Status: Backport [https://github.com/pallets/jinja/pull/1979] | ||
7 | Signed-off-by: Alexander Kanavin <alex@linutronix.de> | ||
8 | --- | ||
9 | src/jinja2/loaders.py | 32 ++++++++++++++++++++++++++------ | ||
10 | tests/test_loader.py | 4 ++-- | ||
11 | 2 files changed, 28 insertions(+), 8 deletions(-) | ||
12 | |||
13 | diff --git a/src/jinja2/loaders.py b/src/jinja2/loaders.py | ||
14 | index 9eaf647..8c2c86c 100644 | ||
15 | --- a/src/jinja2/loaders.py | ||
16 | +++ b/src/jinja2/loaders.py | ||
17 | @@ -238,6 +238,30 @@ class FileSystemLoader(BaseLoader): | ||
18 | return sorted(found) | ||
19 | |||
20 | |||
21 | +if sys.version_info >= (3, 13): | ||
22 | + | ||
23 | + def _get_zipimporter_files(z: t.Any) -> t.Dict[str, object]: | ||
24 | + try: | ||
25 | + get_files = z._get_files | ||
26 | + except AttributeError as e: | ||
27 | + raise TypeError( | ||
28 | + "This zip import does not have the required" | ||
29 | + " metadata to list templates." | ||
30 | + ) from e | ||
31 | + return get_files() | ||
32 | +else: | ||
33 | + | ||
34 | + def _get_zipimporter_files(z: t.Any) -> t.Dict[str, object]: | ||
35 | + try: | ||
36 | + files = z._files | ||
37 | + except AttributeError as e: | ||
38 | + raise TypeError( | ||
39 | + "This zip import does not have the required" | ||
40 | + " metadata to list templates." | ||
41 | + ) from e | ||
42 | + return files # type: ignore[no-any-return] | ||
43 | + | ||
44 | + | ||
45 | class PackageLoader(BaseLoader): | ||
46 | """Load templates from a directory in a Python package. | ||
47 | |||
48 | @@ -382,11 +406,7 @@ class PackageLoader(BaseLoader): | ||
49 | for name in filenames | ||
50 | ) | ||
51 | else: | ||
52 | - if not hasattr(self._loader, "_files"): | ||
53 | - raise TypeError( | ||
54 | - "This zip import does not have the required" | ||
55 | - " metadata to list templates." | ||
56 | - ) | ||
57 | + files = _get_zipimporter_files(self._loader) | ||
58 | |||
59 | # Package is a zip file. | ||
60 | prefix = ( | ||
61 | @@ -395,7 +415,7 @@ class PackageLoader(BaseLoader): | ||
62 | ) | ||
63 | offset = len(prefix) | ||
64 | |||
65 | - for name in self._loader._files.keys(): | ||
66 | + for name in files: | ||
67 | # Find names under the templates directory that aren't directories. | ||
68 | if name.startswith(prefix) and name[-1] != os.path.sep: | ||
69 | results.append(name[offset:].replace(os.path.sep, "/")) | ||
70 | diff --git a/tests/test_loader.py b/tests/test_loader.py | ||
71 | index 77d686e..e0683e4 100644 | ||
72 | --- a/tests/test_loader.py | ||
73 | +++ b/tests/test_loader.py | ||
74 | @@ -364,8 +364,8 @@ def test_package_zip_source(package_zip_loader, template, expect): | ||
75 | |||
76 | |||
77 | @pytest.mark.xfail( | ||
78 | - platform.python_implementation() == "PyPy", | ||
79 | - reason="PyPy's zipimporter doesn't have a '_files' attribute.", | ||
80 | + sys.implementation.name == "pypy", | ||
81 | + reason="zipimporter doesn't have a '_files' attribute", | ||
82 | raises=TypeError, | ||
83 | ) | ||
84 | def test_package_zip_list(package_zip_loader): | ||
85 | -- | ||
86 | 2.39.5 | ||
87 | |||
diff --git a/meta/recipes-devtools/python/python3-jinja2_3.1.4.bb b/meta/recipes-devtools/python/python3-jinja2_3.1.4.bb index f2de1983ce..a11878496c 100644 --- a/meta/recipes-devtools/python/python3-jinja2_3.1.4.bb +++ b/meta/recipes-devtools/python/python3-jinja2_3.1.4.bb | |||
@@ -17,6 +17,7 @@ UPSTREAM_CHECK_PYPI_PACKAGE = "Jinja2" | |||
17 | 17 | ||
18 | SRC_URI += " \ | 18 | SRC_URI += " \ |
19 | file://run-ptest \ | 19 | file://run-ptest \ |
20 | file://fix-3.13.patch \ | ||
20 | " | 21 | " |
21 | 22 | ||
22 | do_install_ptest() { | 23 | do_install_ptest() { |