File: python3.12.patch

package info (click to toggle)
j2cli 0.3.12b-6
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 368 kB
  • sloc: python: 516; makefile: 30; sh: 14; xml: 2
file content (46 lines) | stat: -rw-r--r-- 1,628 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
Description: Replace imp which is deprecated in Python3.12 by importlib
             Fix usage of ConfigParser in Python3.12
Bug-Debian: https://bugs.debian.org/1061745
Author: Andreas Tille <tille@debian.org>
Last-Update: Tue, 13 Feb 2024 20:15:18 +0100

--- a/j2cli/cli.py
+++ b/j2cli/cli.py
@@ -5,7 +5,7 @@ import jinja2
 import jinja2.loaders
 from . import __version__
 
-import imp, inspect
+import importlib, inspect
 
 from .context import read_context_data, FORMATS
 from .extras import filters
@@ -70,7 +70,7 @@ class Jinja2TemplateRenderer(object):
         self.register_tests(self._import_functions(filename))
 
     def _import_functions(self, filename):
-        m = imp.load_source('imported-funcs', filename)
+        m = importlib.machinery.SourceFileLoader('imported-funcs', filename).load_module()
         return dict((name, func) for name, func in inspect.getmembers(m) if inspect.isfunction(func))
 
     def render(self, template_path, context):
@@ -167,7 +167,7 @@ def render_command(cwd, environ, stdin,
     # Customization
     if args.customize is not None:
         customize = CustomizationModule(
-            imp.load_source('customize-module', args.customize)
+            importlib.machinery.SourceFileLoader('customize-module', args.customize).load_module()
         )
     else:
         customize = CustomizationModule(None)
--- a/j2cli/context.py
+++ b/j2cli/context.py
@@ -41,7 +41,7 @@ def _parse_ini(data_string):
 
     # Parse
     ini = MyConfigParser()
-    ini.readfp(ini_file_io(data_string))
+    ini.read_file(ini_file_io(data_string))
 
     # Export
     return ini.as_dict()