Replace Python 'import importlib' with 'import importlib.machinery'

Message ID 20211221140432.2159710-1-thomas@codesourcery.com
State Committed
Headers
Series Replace Python 'import importlib' with 'import importlib.machinery' |

Commit Message

Thomas Schwinge Dec. 21, 2021, 2:04 p.m. UTC
  Fix-up for recent commit f0582fdbf1267f0f34bf3c3b6698b60026410146
"Replace use of deprecated Python 'imp' module with 'importlib'", which...

    [...] 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'

Again, I've asked The Internet what to do about that, and this commit is the
result.  But beware: I'm still not a Python wizard.

	* tests/mockfedabipkgdiff.in: Replace Python 'import importlib'
	with 'import importlib.machinery'.
---
 tests/mockfedabipkgdiff.in | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Comments

Dodji Seketeli Dec. 21, 2021, 3:06 p.m. UTC | #1
Thomas Schwinge <thomas@codesourcery.com> a écrit:

> Fix-up for recent commit f0582fdbf1267f0f34bf3c3b6698b60026410146
> "Replace use of deprecated Python 'imp' module with 'importlib'", which...
>
>     [...] 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'
>
> Again, I've asked The Internet what to do about that, and this commit is the
> result.  But beware: I'm still not a Python wizard.
>
> 	* tests/mockfedabipkgdiff.in: Replace Python 'import importlib'
> 	with 'import importlib.machinery'.

Applied to master.

Cheers,
  
Mark Wielaard Dec. 21, 2021, 3:43 p.m. UTC | #2
Hi,

On Tue, 2021-12-21 at 16:06 +0100, Dodji Seketeli wrote:
> Thomas Schwinge <thomas@codesourcery.com> a écrit:
> 
> > Fix-up for recent commit f0582fdbf1267f0f34bf3c3b6698b60026410146
> > "Replace use of deprecated Python 'imp' module with 'importlib'",
> > which...
> > 
> >     [...] 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'
> > 
> > Again, I've asked The Internet what to do about that, and this
> > commit is the
> > result.  But beware: I'm still not a Python wizard.
> > 
> > 	* tests/mockfedabipkgdiff.in: Replace Python 'import importlib'
> > 	with 'import importlib.machinery'.
> 
> Applied to master.

Sadly still failing:
https://builder.wildebeest.org/buildbot/#/builders/8/builds/802

Note that this is a centos7 install with just python2 and there is no
python3-koji, only python2-koji, which is needed to run the
runtestfedabipkgdiff.py test.

Maybe this test should just be disabled for python2 only systems?

Cheers,

Mark
  
Thomas Schwinge Dec. 21, 2021, 4:19 p.m. UTC | #3
Hi!

On 2021-12-21T16:43:40+0100, Mark Wielaard <mark@klomp.org> wrote:
> On Tue, 2021-12-21 at 16:06 +0100, Dodji Seketeli wrote:
>> Thomas Schwinge <thomas@codesourcery.com> a écrit:
>> > Fix-up for recent commit f0582fdbf1267f0f34bf3c3b6698b60026410146
>> > "Replace use of deprecated Python 'imp' module with 'importlib'",
>> > which...
>> >
>> >     [...] 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'
>> >
>> > Again, I've asked The Internet what to do about that, and this
>> > commit is the
>> > result.  But beware: I'm still not a Python wizard.
>> >
>> >    * tests/mockfedabipkgdiff.in: Replace Python 'import importlib'
>> >    with 'import importlib.machinery'.
>>
>> Applied to master.
>
> Sadly still failing:
> https://builder.wildebeest.org/buildbot/#/builders/8/builds/802

I'm sorry for the repeated breakage.

> Note that this is a centos7 install with just python2

Aha -- Python 2.  And yes, I now see that I'm able to reproduce the
problem with Python 2; I'll send another patch later.

> and there is no
> python3-koji, only python2-koji, which is needed to run the
> runtestfedabipkgdiff.py test.

Well, regarding that one, see my recent
commit feb441e284a03f3ff86fd0962cfaf5a9efedf28d
"fedabipkgdiff: Enable testing without proper Koji installation".  ;-D

> Maybe this test should just be disabled for python2 only systems?

No.  It use to work, and should continue to.  Let me give it one more
try...


Grüße
 Thomas
-----------------
Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201, 80634 München; Gesellschaft mit beschränkter Haftung; Geschäftsführer: Thomas Heurung, Frank Thürauf; Sitz der Gesellschaft: München; Registergericht München, HRB 106955
  

Patch

diff --git a/tests/mockfedabipkgdiff.in b/tests/mockfedabipkgdiff.in
index 7de42b86..29a28ad9 100644
--- a/tests/mockfedabipkgdiff.in
+++ b/tests/mockfedabipkgdiff.in
@@ -39,7 +39,7 @@  variables.
 
 import os
 import tempfile
-import importlib
+import importlib.machinery
 import six
 
 try: