Re: [spice-common] codegen: Use six.PY3 rather than six.PY2

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

 



Good to know.  Which distro has that version?

Also, changes look correct.

On Wed, 15 Apr 2015 16:03:22 +0200
Christophe Fergeau <cfergeau@xxxxxxxxxx> wrote:

> Older versions of python-six (at least 1.3.0) defined six.PY3 but not
> six.PY2. six.PY2 is only used twice in straightforward tests so it's
> easy to use six.PY3 instead.
> ---
>  python_modules/codegen.py | 6 +++---
>  spice_codegen.py          | 6 +++---
>  2 files changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/python_modules/codegen.py b/python_modules/codegen.py
> index 55f513b..f324498 100644
> --- a/python_modules/codegen.py
> +++ b/python_modules/codegen.py
> @@ -121,10 +121,10 @@ class CodeWriter:
>  
>      def write(self, s):
>          # Ensure its a unicode string
> -        if six.PY2:
> -            s = unicode(s)
> -        else:
> +        if six.PY3:
>              s = str(s)
> +        else:
> +            s = unicode(s)
>  
>          if len(s) == 0:
>              return
> diff --git a/spice_codegen.py b/spice_codegen.py
> index 16ad478..84790af 100755
> --- a/spice_codegen.py
> +++ b/spice_codegen.py
> @@ -265,10 +265,10 @@ if options.keep_identical_file:
>          pass
>  
>  f = open(dest_file, 'wb')
> -if six.PY2:
> -    f.write(content)
> -else:
> +if six.PY3:
>      f.write(bytes(content, 'UTF-8'))
> +else:
> +    f.write(content)
>  f.close()
>  
>  six.print_("Wrote %s" % dest_file)

Attachment: pgpp4sua42dhx.pgp
Description: OpenPGP digital signature

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/spice-devel

[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]