From 679be53bf46ef1b7e8bc7f957e638620e67a544a Mon Sep 17 00:00:00 2001 From: juur 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 --- 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