Skip to content

Commit

Permalink
Fix to deserializer if result type does not have a length
Browse files Browse the repository at this point in the history
An exception will be thrown if a bool is returned from a SOAP service call.
`deserialize` soap.py will ask for the length of the result body, but it may not be allowed to take len on some result body types.
Added check if length is valid and returns the body directly if it is not.
I haven't tested with any other types, such as integers.
  • Loading branch information
holstebroe authored and mvantellingen committed Mar 17, 2023
1 parent d0d737a commit 377d931
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/zeep/wsdl/messages/soap.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@ def deserialize(self, envelope):
return result

result = result.body
if not hasattr(result, '__len__'): # Return body directly if len is allowed (could indicated valid primitive type).
return result
if result is None or len(result) == 0:
return None
elif len(result) > 1:
Expand Down

1 comment on commit 377d931

@thijsvandien
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the code comment accurate? It seems to state the opposite of how it works and what the commit describes.

Please sign in to comment.