void-packages/srcpkgs/gramps/patches/1411.patch

48 lines
1.8 KiB
Diff

https://github.com/gramps-project/gramps/pull/1411
From 47f392ef70618cfece86e5210c19c2c1a768a4e0 Mon Sep 17 00:00:00 2001
From: David Straub <straub@protonmail.com>
Date: Mon, 6 Feb 2023 17:12:28 +0100
Subject: [PATCH] Replace deprecated imp by importlib
---
gramps/gen/plug/_manager.py | 10 +++-------
gramps/plugins/importer/importgedcom.py | 4 ++--
2 files changed, 5 insertions(+), 9 deletions(-)
diff --git a/gramps/gen/plug/_manager.py b/gramps/gen/plug/_manager.py
index 1077de0cdb..16474d5b6e 100644
--- a/gramps/gen/plug/_manager.py
+++ b/gramps/gen/plug/_manager.py
@@ -372,13 +372,9 @@ def reload(self, module, pdata):
Reloads modules that might not be in the path.
"""
try:
- import imp
- fp, pathname, description = imp.find_module(pdata.mod_name, [pdata.fpath])
- try:
- module = imp.load_module(pdata.mod_name, fp, pathname,description)
- finally:
- if fp:
- fp.close()
+ spec = importlib.util.find_spec(pdata.mod_name, [pdata.fpath])
+ module = importlib.util.module_from_spec(spec)
+ spec.loader.exec_module(module)
except:
if pdata.mod_name in sys.modules:
del sys.modules[pdata.mod_name]
diff --git a/gramps/plugins/importer/importgedcom.py b/gramps/plugins/importer/importgedcom.py
index ac2c604447..f2fa7fd5a4 100644
--- a/gramps/plugins/importer/importgedcom.py
+++ b/gramps/plugins/importer/importgedcom.py
@@ -47,8 +47,8 @@
# a quick turnround, without having to restart Gramps.
module = __import__("gramps.plugins.lib.libgedcom",
fromlist=["gramps.plugins.lib"]) # why o why ?? as above!
-import imp
-imp.reload(module)
+import importlib
+importlib.reload(module)
from gramps.gen.config import config