mirror of
https://gitlab.alpinelinux.org/alpine/aports.git
synced 2026-01-11 11:41:59 +01:00
Version 0.8.2 of jinja2-cli as the latest available upstream release doesn't
work with Python 3.12+. When invoked to generate a template, it fails with:
Traceback (most recent call last):
File "/usr/bin/jinja2", line 8, in <module>
sys.exit(main())
^^^^^^
File "[...]/jinja2cli/cli.py", line 449, in main
sys.exit(cli(opts, args))
^^^^^^^^^^^^^^^
File "[...]/jinja2cli/cli.py", line 304, in cli
data = fn(data) or {}
^^^^^^^^
File "[...]/jinja2cli/cli.py", line 126, in _parse_ini
p.readfp(StringIO(data))
^^^^^^^^
AttributeError: 'MyConfigParser' object has no attribute 'readfp'. Did you
mean: 'read'?
Fix that by backporting the upstream patch from [0].
[0]: https://github.com/mattrobenolt/jinja2-cli/pull/132
37 lines
1.1 KiB
Diff
37 lines
1.1 KiB
Diff
From 679be53bf46ef1b7e8bc7f957e638620e67a544a Mon Sep 17 00:00:00 2001
|
|
From: juur <juur@users.noreply.github.com>
|
|
Date: Thu, 17 Oct 2024 21:15:18 +0100
|
|
Subject: [PATCH] Update cli.py (#132)
|
|
|
|
* Update cli.py
|
|
|
|
readfp is not available in Python 3.12.
|
|
|
|
* Update cli.py
|
|
|
|
Support Python 2 as well as Python 3.12+
|
|
|
|
Upstream-Status: Backport [https://github.com/mattrobenolt/jinja2-cli/commit/679be53bf46ef1b7e8bc7f957e638620e67a544a]
|
|
Signed-off-by: Moritz Haase <Moritz.Haase@bmw.de>
|
|
---
|
|
jinja2cli/cli.py | 6 +++++-
|
|
1 file changed, 5 insertions(+), 1 deletion(-)
|
|
|
|
diff --git a/jinja2cli/cli.py b/jinja2cli/cli.py
|
|
index dc2449525b60ac66d33b6e9a0fdaa0476a69680f..5a3dc0a35a4aef3d5c06c08817a9e80faaa9ad86 100644
|
|
--- a/jinja2cli/cli.py
|
|
+++ b/jinja2cli/cli.py
|
|
@@ -131,7 +131,11 @@ def as_dict(self):
|
|
return d
|
|
|
|
p = MyConfigParser()
|
|
- p.readfp(StringIO(data))
|
|
+ try:
|
|
+ reader = p.readfp
|
|
+ except AttributeError:
|
|
+ reader = p.read_file
|
|
+ reader(StringIO(data))
|
|
return p.as_dict()
|
|
|
|
return _parse_ini, ConfigParser.Error, MalformedINI
|