Re: [virt-bootstrap] [PATCH] test: python 2/3 compatability

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, 2017-09-05 at 09:35 +0100, Radostin Stoyanov wrote:
> The function read_file() from the python bindings of libguestfs
> returns value of type "str" Python 2 and type "bytes" for Python 3.
> 
> To use split() we need to convert the type 'bytes' into 'str' using
> decode().

Huh... the comment seems weird. libguestfs returns a str in both cases,
just that python3 strings have some incompatibility with python2 ones.

> ---
>  tests/docker_source.py | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/tests/docker_source.py b/tests/docker_source.py
> index 9090988..71e3e40 100644
> --- a/tests/docker_source.py
> +++ b/tests/docker_source.py
> @@ -181,7 +181,9 @@ class TestQcow2DockerSource(Qcow2ImageAccessor):
>          cmd = ['qemu-img', 'info', image_path]
>          proc = subprocess.Popen(cmd, stdout=subprocess.PIPE)
>          output, _ignore = proc.communicate()
> -        return output.decode('utf-8').split('\n')
> +        if hasattr(output, 'decode'):
> +            output = output.decode('utf-8')
> +        return output.split('\n')
>  

Are you sure you don't have some pending work? The code I have doesn't
match exactly this one.

--
Cedric

>      def call_bootstrap(self):
>          """

_______________________________________________
virt-tools-list mailing list
virt-tools-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/virt-tools-list




[Index of Archives]     [Linux Virtualization]     [KVM Development]     [CentOS Virtualization]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]     [Video 4 Linux]

  Powered by Linux