From e4ab01d960a455dd83f85a76864b19908df4219f Mon Sep 17 00:00:00 2001 From: DistroBaker Date: Sat, 6 Feb 2021 13:14:24 +0000 Subject: [PATCH] Merged update from upstream sources This is an automated DistroBaker update from upstream sources. If you do not know what this is about or would like to opt out, contact the OSCI team. Source: https://src.fedoraproject.org/rpms/python-jinja2.git#93898ae45c1e90f2e9c41a49126884cb5be93ffc --- ...-the-preserved-CodeType-attributes-1.patch | 27 ++++++++++ ...at-pass-only-strings-to-literal_eval.patch | 49 +++++++++++++++++++ python-jinja2.spec | 13 +++-- sources | 2 +- 4 files changed, 87 insertions(+), 4 deletions(-) create mode 100644 0001-add-linetable-to-the-preserved-CodeType-attributes-1.patch create mode 100644 0002-native_concat-pass-only-strings-to-literal_eval.patch diff --git a/0001-add-linetable-to-the-preserved-CodeType-attributes-1.patch b/0001-add-linetable-to-the-preserved-CodeType-attributes-1.patch new file mode 100644 index 0000000..7840d4f --- /dev/null +++ b/0001-add-linetable-to-the-preserved-CodeType-attributes-1.patch @@ -0,0 +1,27 @@ +From 9a99db929323f60553b391c80d0395821121d593 Mon Sep 17 00:00:00 2001 +From: Thomas Moschny +Date: Tue, 19 Jan 2021 21:01:18 +0100 +Subject: [PATCH] add 'linetable' to the preserved CodeType attributes (#1334) + +add 'linetable' to the preserved CodeType attributes + +co_linetable replaces co_lnotab as part of PEP 626 in Python 3.10. +--- + src/jinja2/debug.py | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/src/jinja2/debug.py b/src/jinja2/debug.py +index 5d8aec3..e256617 100644 +--- a/src/jinja2/debug.py ++++ b/src/jinja2/debug.py +@@ -137,6 +137,7 @@ def fake_traceback(exc_value, tb, filename, lineno): + "lnotab", + "freevars", + "cellvars", ++ "linetable", # Python 3.10 + ): + if isinstance(attr, tuple): + # Replace with given value. +-- +2.29.2 + diff --git a/0002-native_concat-pass-only-strings-to-literal_eval.patch b/0002-native_concat-pass-only-strings-to-literal_eval.patch new file mode 100644 index 0000000..3e0e76a --- /dev/null +++ b/0002-native_concat-pass-only-strings-to-literal_eval.patch @@ -0,0 +1,49 @@ +From 58250a709532ccb3e6d92ca65b3d305d1464cb68 Mon Sep 17 00:00:00 2001 +From: Martin Krizek +Date: Thu, 28 Jan 2021 10:08:50 +0100 +Subject: [PATCH] native_concat: pass only strings to literal_eval + +If there is only single node and it is not a string, there is no point +in passing it into ``literal_eval``, just return it immediately. + +One of the examples where passing a non-string node into +``literal_eval`` would actually cause problems is when the node is +``Undefined``. On Python 3.10 this would cause ``UndefinedError`` +instead of just ``Undefined`` being returned. + +Fixes #1335 +--- + CHANGES.rst | 3 +++ + src/jinja2/nativetypes.py | 2 ++ + 2 files changed, 5 insertions(+) + +diff --git a/CHANGES.rst b/CHANGES.rst +index 511b22b..a8a66ea 100644 +--- a/CHANGES.rst ++++ b/CHANGES.rst +@@ -8,6 +8,9 @@ Released 2021-01-31 + - Improve the speed of the ``urlize`` filter by reducing regex + backtracking. Email matching requires a word character at the start + of the domain part, and only word characters in the TLD. :pr:`1343` ++- Fix UndefinedError incorrectly being thrown on an undefined variable ++ instead of ``Undefined`` being returned on ++ ``NativeEnvironment`` on Python 3.10. :issue:`1335` + + + Version 2.11.2 +diff --git a/src/jinja2/nativetypes.py b/src/jinja2/nativetypes.py +index a9ead4e..2fee17f 100644 +--- a/src/jinja2/nativetypes.py ++++ b/src/jinja2/nativetypes.py +@@ -26,6 +26,8 @@ def native_concat(nodes): + + if len(head) == 1: + raw = head[0] ++ if not isinstance(raw, str): ++ return raw + else: + raw = u"".join([text_type(v) for v in chain(head, nodes)]) + +-- +2.29.2 + diff --git a/python-jinja2.spec b/python-jinja2.spec index 5375b73..3cb3a79 100644 --- a/python-jinja2.spec +++ b/python-jinja2.spec @@ -1,12 +1,15 @@ %global srcname Jinja2 Name: python-jinja2 -Version: 2.11.2 -Release: 8%{?dist} +Version: 2.11.3 +Release: 1%{?dist} Summary: General purpose template engine License: BSD URL: https://palletsprojects.com/p/jinja/ Source0: %{pypi_source} +# cherry-picked patches to build with Python 3.10 (#1907442) +Patch1: 0001-add-linetable-to-the-preserved-CodeType-attributes-1.patch +Patch2: 0002-native_concat-pass-only-strings-to-literal_eval.patch %if 0%{?fedora} || 0%{?rhel} > 7 # Enable python3 build by default @@ -105,7 +108,7 @@ environments. %prep -%autosetup -n %{srcname}-%{version} +%autosetup -p1 -n %{srcname}-%{version} # cleanup find . -name '*.pyo' -o -name '*.pyc' -delete @@ -180,6 +183,10 @@ PYTHONPATH=$(pwd)/src %{__python3} -m pytest tests %changelog +* Sat Feb 6 2021 Thomas Moschny - 2.11.3-1 +- Update to 2.11.3. +- Add patches to build with Python 3.10 (#1907442). + * Wed Jan 27 2021 Fedora Release Engineering - 2.11.2-8 - Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild diff --git a/sources b/sources index 1a05893..a742c89 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -SHA512 (Jinja2-2.11.2.tar.gz) = baf62118702a7e113e6a22d9af58a5fa66af8017ded08f18705107a4cb93c9727c7fa118436aadfe0729d7f496241ca7bcce27863c5b19deaee3852eda68c082 +SHA512 (Jinja2-2.11.3.tar.gz) = fce4f835795fe9afb622f8106f60344032a811f3f693806f31ba482f9b7c1400f93dfa1701b4db0b472cbed4b0793cb329778c8091811ef0e3b577150d28e004