[Spice-devel] [spice-common] codegen: Fix enums.h generation with python3

Fabiano FidĂȘncio fabiano at fidencio.org
Wed Jul 22 05:15:10 PDT 2015


On Wed, Jul 22, 2015 at 12:51 PM, Christophe Fergeau
<cfergeau at redhat.com> wrote:
> Trying to generate enums.h with python3 results in
> Traceback (most recent call last):
>   File "./spice_codegen.py", line 217, in <module>
>     write_enums(writer, options.generate_dissector)
>   File "./spice_codegen.py", line 99, in write_enums
>     write_channel_enums(writer, c, False, False)
>   File "./spice_codegen.py", line 17, in write_channel_enums
>     if len(messages) == 0:
> TypeError: object of type 'filter' has no len()
>
> filter() returns an enumerator object in python3 while it used to return
> a list in python2. Using list(filter()) instead fixes that error.
> I've checked that the generated enums.h is identical with python2 and
> python3.
> ---
>  spice_codegen.py | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/spice_codegen.py b/spice_codegen.py
> index 84790af..569cccc 100755
> --- a/spice_codegen.py
> +++ b/spice_codegen.py
> @@ -12,8 +12,8 @@ from python_modules import marshal
>  import six
>
>  def write_channel_enums(writer, channel, client, describe):
> -    messages = filter(lambda m : m.channel == channel, \
> -                          channel.client_messages if client else channel.server_messages)
> +    messages = list(filter(lambda m : m.channel == channel, \
> +                               channel.client_messages if client else channel.server_messages))
>      if len(messages) == 0:
>          return
>      if client:
> --
> 2.4.3
>
> _______________________________________________
> Spice-devel mailing list
> Spice-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/spice-devel


ACK!
-- 
Fabiano FidĂȘncio


More information about the Spice-devel mailing list