[PATCH] kunit: tool: Import missing importlib.abc

Michał Winiarski posted 1 patch 4 years, 5 months ago
tools/testing/kunit/kunit_kernel.py | 1 +
1 file changed, 1 insertion(+)
[PATCH] kunit: tool: Import missing importlib.abc
Posted by Michał Winiarski 4 years, 5 months ago
Python 3.10.0 contains:
9e09849d20 ("bpo-41006: importlib.util no longer imports typing (GH-20938)")

It causes importlib.util to no longer import importlib.abs, which leads
to the following error when trying to use kunit with qemu:
AttributeError: module 'importlib' has no attribute 'abc'. Did you mean: '_abc'?

Add the missing import.

Signed-off-by: Michał Winiarski <michal.winiarski@intel.com>
---
 tools/testing/kunit/kunit_kernel.py | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tools/testing/kunit/kunit_kernel.py b/tools/testing/kunit/kunit_kernel.py
index 44bbe54f25f1..3c4196cef3ed 100644
--- a/tools/testing/kunit/kunit_kernel.py
+++ b/tools/testing/kunit/kunit_kernel.py
@@ -6,6 +6,7 @@
 # Author: Felix Guo <felixguoxiuping@gmail.com>
 # Author: Brendan Higgins <brendanhiggins@google.com>
 
+import importlib.abc
 import importlib.util
 import logging
 import subprocess
-- 
2.34.1

Re: [PATCH] kunit: tool: Import missing importlib.abc
Posted by Daniel Latypov 4 years, 5 months ago
On Wed, Jan 12, 2022 at 3:35 PM Michał Winiarski
<michal.winiarski@intel.com> wrote:
>
> Python 3.10.0 contains:
> 9e09849d20 ("bpo-41006: importlib.util no longer imports typing (GH-20938)")
>
> It causes importlib.util to no longer import importlib.abs, which leads
> to the following error when trying to use kunit with qemu:
> AttributeError: module 'importlib' has no attribute 'abc'. Did you mean: '_abc'?
>
> Add the missing import.
>
> Signed-off-by: Michał Winiarski <michal.winiarski@intel.com>

Reviewed-by: Daniel Latypov <dlatypov@google.com>

Thanks for catching this! I completely forgot to add the import.

For context to others, the relevant line is
216          assert isinstance(spec.loader, importlib.abc.Loader)
which was added by me in commit 52a5d80a2225 ("kunit: tool: fix
typecheck errors about loading qemu configs").

We could potentially add a Fixes: tag on this, but this looks good to me.

> ---
>  tools/testing/kunit/kunit_kernel.py | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/tools/testing/kunit/kunit_kernel.py b/tools/testing/kunit/kunit_kernel.py
> index 44bbe54f25f1..3c4196cef3ed 100644
> --- a/tools/testing/kunit/kunit_kernel.py
> +++ b/tools/testing/kunit/kunit_kernel.py
> @@ -6,6 +6,7 @@
>  # Author: Felix Guo <felixguoxiuping@gmail.com>
>  # Author: Brendan Higgins <brendanhiggins@google.com>
>
> +import importlib.abc
>  import importlib.util
>  import logging
>  import subprocess
> --
> 2.34.1
>
Re: [PATCH] kunit: tool: Import missing importlib.abc
Posted by Brendan Higgins 4 years, 5 months ago
On Wed, Jan 12, 2022 at 6:35 PM Michał Winiarski
<michal.winiarski@intel.com> wrote:
>
> Python 3.10.0 contains:
> 9e09849d20 ("bpo-41006: importlib.util no longer imports typing (GH-20938)")
>
> It causes importlib.util to no longer import importlib.abs, which leads
> to the following error when trying to use kunit with qemu:
> AttributeError: module 'importlib' has no attribute 'abc'. Did you mean: '_abc'?
>
> Add the missing import.
>
> Signed-off-by: Michał Winiarski <michal.winiarski@intel.com>

Thanks!

Reviewed-by: Brendan Higgins <brendanhiggins@google.com>