Re: [virt-bootstrap][PATCH 2/7] python3 compat: python3 strings have no decode()

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

 



On 05/09/17 17:41, Cédric Bosdonnat wrote:
> Since python3 strings are already Unicode-capable, there have no
> decode() function. Libguestfs content strings can be either python 2
> or 3 strings, only decode them to utf-8 for python2.
> ---
>  src/virtBootstrap/utils.py | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/src/virtBootstrap/utils.py b/src/virtBootstrap/utils.py
> index 1fb3625..f696471 100644
> --- a/src/virtBootstrap/utils.py
> +++ b/src/virtBootstrap/utils.py
> @@ -168,7 +168,9 @@ class BuildImage(object):
>          self.g.mount('/dev/sda', '/')
>          success = False
>          if self.g.is_file('/etc/shadow'):
> -            shadow_content = self.g.read_file('/etc/shadow').decode('utf-8')
> +            shadow_content = self.g.read_file('/etc/shadow')
> +            if hasattr(shadow_content, 'decode'):
> +                shadow_content = shadow_content.decode('utf-8')
>              shadow_content = shadow_content.split('\n')
>              if shadow_content:
>                  # Note: 'shadow_content' is a list, pass-by-reference is used
ACK

_______________________________________________
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