Package: glueviz
Version: 1.0.1+dfsg-3
Tag: patch

I am attaching a patch that replaces the use of package imp by importlib.

Regards,
Pushkar
diff --git a/debian/patches/Replace-imp-by-importlib.patch b/debian/patches/Replace-imp-by-importlib.patch
new file mode 100644
index 0000000..fd5a5a0
--- /dev/null
+++ b/debian/patches/Replace-imp-by-importlib.patch
@@ -0,0 +1,37 @@
+Author: Pushkar Kulkarni <pushkar.kulka...@canonical.com>
+Description: The "imp" package lets users implement the import statement,
+    enabling dynamic loading of Python modules. The "imp" package was
+    deprecated in an earlier version and removed in Python 3.12. The
+    Python3 docs recommend moving to package "importlib" as a replacement.
+Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1061799
+--- a/glue/config.py
++++ b/glue/config.py
+@@ -1,8 +1,10 @@
+ import os
+-import imp
++import importlib
+ import sys
++import types
+ import warnings
+ from collections import namedtuple
++from importlib.machinery import SourceFileLoader
+ 
+ from glue.utils import format_choices
+ 
+@@ -994,13 +996,14 @@
+        Exception, if no module was found
+     """
+     search_order = search_path or _default_search_order()
+-    result = imp.new_module('config')
++    # Create a new, empty module
++    result = types.ModuleType('config')
+ 
+     for config_file in search_order:
+         dir = os.path.dirname(config_file)
+         try:
+             sys.path.append(dir)
+-            config = imp.load_source('config', config_file)
++            config = SourceFileLoader('config', config_file).load_module()
+             result = config
+         except IOError:
+             pass
diff --git a/debian/patches/series b/debian/patches/series
index 14a4a22..9e89a04 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -4,3 +4,4 @@ Install-in-proper-directory-.txt-file.patch
 Add-Keywords-to-desktop-file.patch
 Install-under-the-right-directory-the-package-data.patch
 Pass-int-argument-to-QProgressBar.setValue.patch
+Replace-imp-by-importlib.patch

Reply via email to