On Thu, May 07, 2020 at 09:26:29AM +0200, Christian Ehrhardt wrote:
> Without this fix in a pure python3 environment this will run into
> issues like:
>   ModuleNotFoundError: No module named 'StringIO'
> or later string encoding issues on check_output.
> 
> Signed-off-by: Christian Ehrhardt <christian.ehrha...@canonical.com>
> ---
>  app/test/autotest_runner.py | 16 +++++++---------
>  1 file changed, 7 insertions(+), 9 deletions(-)
> 
> diff --git a/app/test/autotest_runner.py b/app/test/autotest_runner.py
> index 95e74c760d..dfa5f2b2dd 100644
> --- a/app/test/autotest_runner.py
> +++ b/app/test/autotest_runner.py
> @@ -4,7 +4,7 @@
>  # The main logic behind running autotests in parallel
>  
>  from __future__ import print_function
> -import StringIO
> +import io
>  import csv
>  from multiprocessing import Pool, Queue
>  import pexpect
> @@ -45,11 +45,9 @@ def get_numa_nodes():
>  def first_cpu_on_node(node_nr):
>      cpu_path = glob.glob("/sys/devices/system/node/node%d/cpu*" % node_nr)
>      r = re.compile(r"cpu(\d+)")
> -    cpu_name = filter(None,
> -            map(r.match,
> -                map(os.path.basename, cpu_path)
> -            )
> -    )
> +    cpu_name = [_f for _f in map(r.match,
> +                list(map(os.path.basename, cpu_path))
> +            ) if _f]
>      # for compatibility between python 3 and 2 we need to make interable out
>      # of filter return as it returns list in python 2 and a generator in 3
>      m = next(iter(cpu_name))

If this is python3 only, then you can remove the "iter()" call above and
the comment about the python2 compatibility.

/Bruce

Reply via email to