[Spice-devel] [PATCH spice-common] Remove extra self parameter from member function

Lukáš Hrázký lhrazky at redhat.com
Wed Apr 11 07:28:37 UTC 2018


On Tue, 2018-04-10 at 16:29 -0500, Jonathon Jongsma wrote:
> When testing out some experimental protocol changes, I managed to
> trigger the following error:
> 
>   GEN      generated_client_demarshallers.c
> Traceback (most recent call last):
>   File "../../../spice-common/spice_codegen.py", line 267, in <module>
>     demarshal.write_protocol_parser(writer, proto, True)
>   File "/home/jjongsma/work/spice/spice-common/python_modules/demarshal.py", line 1270, in write_protocol_parser
>     parsers[channel.value] = (channel.channel_type, write_channel_parser(writer, channel.channel_type, is_server))
>   File "/home/jjongsma/work/spice/spice-common/python_modules/demarshal.py", line 1163, in write_channel_parser
>     func = write_msg_parser(helpers, ids[i].message_type)
>   File "/home/jjongsma/work/spice/spice-common/python_modules/demarshal.py", line 1061, in write_msg_parser
>     num_pointers = message.get_num_pointers()
>   File "/home/jjongsma/work/spice/spice-common/python_modules/ptypes.py", line 855, in get_num_pointers
>     count = count + m.get_num_pointers()
>   File "/home/jjongsma/work/spice/spice-common/python_modules/ptypes.py", line 662, in get_num_pointers
>     return self.member_type.get_num_pointers()
>   File "/home/jjongsma/work/spice/spice-common/python_modules/ptypes.py", line 507, in get_num_pointers
>     if self.is_constant_length(self):
> TypeError: is_constant_length() takes exactly 1 argument (2 given)
> 
> Calling a member function will implicitly pass 'self' as the first
> argument, but we were also explicitly passing it as an argument
> (self.is_constant_length(self)). This resulted in the above error.
> ---
>  python_modules/ptypes.py | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/python_modules/ptypes.py b/python_modules/ptypes.py
> index 63a7a2f..d29c97a 100644
> --- a/python_modules/ptypes.py
> +++ b/python_modules/ptypes.py
> @@ -504,7 +504,7 @@ class ArrayType(Type):
>          element_count = self.element_type.get_num_pointers()
>          if element_count  == 0:
>              return 0
> -        if self.is_constant_length(self):
> +        if self.is_constant_length():
>              return element_count * self.size
>          raise Exception("Pointers in dynamic arrays not supported")

Acked-by: Lukáš Hrázký <lhrazky at redhat.com>


More information about the Spice-devel mailing list