diff --git a/174.patch b/174.patch new file mode 100644 index 0000000..96cef6f --- /dev/null +++ b/174.patch @@ -0,0 +1,61 @@ +From 3d6cf72cf21fba816744702d342545265e67233f Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= +Date: Tue, 18 May 2021 12:31:51 +0200 +Subject: [PATCH] Implement DynamicImporter.find_spec() + +On Python 3.10, the code raised an ImportWarning: + + ImportWarning: DynamicImporter.find_spec() not found; falling back to find_module() + +See https://docs.python.org/3.10/whatsnew/3.10.html#deprecated + +> Starting in this release, there will be a concerted effort to begin cleaning +> up old import semantics that were kept for Python 2.7 compatibility. +> Specifically, find_loader()/find_module() (superseded by find_spec()), +> load_module() (superseded by exec_module()), module_repr() +> (which the import system takes care of for you), +> the __package__ attribute (superseded by __spec__.parent), +> the __loader__ attribute (superseded by __spec__.loader), +> and the __cached__ attribute (superseded by __spec__.cached) +> will slowly be removed (as well as other classes and methods in importlib). +> ImportWarning and/or DeprecationWarning will be raised as appropriate to help +> identify code which needs updating during this transition. + +Fixes https://gitlab.gnome.org/GNOME/pygobject/-/issues/473 +--- + gi/importer.py | 15 ++++++++++----- + 1 file changed, 10 insertions(+), 5 deletions(-) + +diff --git a/gi/importer.py b/gi/importer.py +index 32967974..63788776 100644 +--- a/gi/importer.py ++++ b/gi/importer.py +@@ -107,15 +107,20 @@ class DynamicImporter(object): + def __init__(self, path): + self.path = path + +- def find_module(self, fullname, path=None): ++ def _find_module_check(self, fullname): + if not fullname.startswith(self.path): +- return ++ return False + + path, namespace = fullname.rsplit('.', 1) +- if path != self.path: +- return ++ return path == self.path ++ ++ def find_spec(self, fullname, path=None, target=None): ++ if self._find_module_check(fullname): ++ return importlib.util.spec_from_loader(fullname, self) + +- return self ++ def find_module(self, fullname, path=None): ++ if self._find_module_check(fullname): ++ return self + + def load_module(self, fullname): + if fullname in sys.modules: +-- +GitLab + diff --git a/pygobject3.spec b/pygobject3.spec index 46da265..5a4730d 100644 --- a/pygobject3.spec +++ b/pygobject3.spec @@ -6,9 +6,14 @@ Name: pygobject3 Version: 3.40.1 -Release: 2%{?dist} +Release: 3%{?dist} Summary: Python bindings for GObject Introspection +# pygobject3 emits an ImportWarning with Pyuthon 3.10.0b1+ +# This patch fixes this error and can be removed once merged in upstream +# https://gitlab.gnome.org/GNOME/pygobject/-/merge_requests/174 +Patch174: 174.patch + License: LGPLv2+ and MIT URL: https://wiki.gnome.org/Projects/PyGObject Source0: https://download.gnome.org/sources/pygobject/3.40/pygobject-%{version}.tar.xz @@ -85,6 +90,10 @@ This package contains files required to embed PyGObject %{_libdir}/pkgconfig/pygobject-3.0.pc %changelog +* Thu May 20 2021 Tomas Hrnciar - 3.40.1-3 +- Backport upstream PR to fix ImportWarning: DynamicImporter.find_spec() not found +- Fixes: rhbz#1958890 + * Wed May 05 2021 Ray Strode - 3.40.1-2 - Add concurrency fix Related: #1957130