Replace use of deprecated Python 'imp' module with 'importlib'
Commit Message
In the test logs, I've found a number of:
[...]/tests/mockfedabipkgdiff:42: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses
import imp
I've asked The Internet what to do about that, and this commit is the result.
But beware: I'm not a Python wizard.
* tests/mockfedabipkgdiff.in: Replace use of deprecated Python
'imp' module with 'importlib'.
CC: Chenxiong Qi <cqi@redhat.com>
Signed-off-by: Thomas Schwinge <thomas@codesourcery.com>
---
tests/mockfedabipkgdiff.in | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
Comments
Thomas Schwinge <thomas@codesourcery.com> a écrit:
> In the test logs, I've found a number of:
>
> [...]/tests/mockfedabipkgdiff:42: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses
> import imp
>
> I've asked The Internet what to do about that, and this commit is the result.
> But beware: I'm not a Python wizard.
>
> * tests/mockfedabipkgdiff.in: Replace use of deprecated Python
> 'imp' module with 'importlib'.
>
> CC: Chenxiong Qi <cqi@redhat.com>
> Signed-off-by: Thomas Schwinge <thomas@codesourcery.com>
Applied to master. Thanks!
[...]
Cheers,
Hi,
On Tue, 2021-12-21 at 14:31 +0100, Dodji Seketeli wrote:
> Thomas Schwinge <thomas@codesourcery.com> a écrit:
>
> > In the test logs, I've found a number of:
> >
> > [...]/tests/mockfedabipkgdiff:42: DeprecationWarning: the imp
> > module is deprecated in favour of importlib; see the module's
> > documentation for alternative uses
> > import imp
> >
> > I've asked The Internet what to do about that, and this commit is
> > the result.
> > But beware: I'm not a Python wizard.
> >
> > * tests/mockfedabipkgdiff.in: Replace use of deprecated Python
> > 'imp' module with 'importlib'.
> >
> > CC: Chenxiong Qi <cqi@redhat.com>
> > Signed-off-by: Thomas Schwinge <thomas@codesourcery.com>
>
> Applied to master. Thanks!
The buildbot is a little slow being busy with elfutil commits:
https://builder.wildebeest.org/buildbot/#/pendingbuildrequests
But this seems to have broken something on centos7 x86_64:
https://builder.wildebeest.org/buildbot/#/changes/7273
File "/srv/buildbot/worker/libabigail-centos-
x86_64/build/tests/mockfedabipkgdiff", line 73, in <module>
fedabipkgdiff_mod =
importlib.machinery.SourceFileLoader('fedabipkgdiff',
FEDABIPKGDIFF).load_module()
AttributeError: 'module' object has no attribute 'machinery'
Cheers,
Mark
@@ -39,7 +39,7 @@ variables.
import os
import tempfile
-import imp
+import importlib
import six
try:
@@ -70,7 +70,7 @@ def get_download_dir():
# Import the fedabipkgdiff program file from the source directory.
-fedabipkgdiff_mod = imp.load_source('fedabipkgdiff', FEDABIPKGDIFF)
+fedabipkgdiff_mod = importlib.machinery.SourceFileLoader('fedabipkgdiff', FEDABIPKGDIFF).load_module()
# ----------------- Koji resource storage begins ------------------