Skip to content

Commit

Permalink
Fix unexpected attribute error
Browse files Browse the repository at this point in the history
  • Loading branch information
vladbarosan committed Oct 1, 2020
1 parent ca20945 commit 139a079
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
5 changes: 4 additions & 1 deletion apitools/base/protorpclite/protojson.py
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,10 @@ def decode_field(self, field, value):

elif (isinstance(field, messages.MessageField) and
issubclass(field.type, messages.Message)):
return self.__decode_dictionary(field.type, value)
try:
return self.__decode_dictionary(field.type, value)
except AttributeError as err:
raise messages.DecodeError(err)

elif (isinstance(field, messages.FloatField) and
isinstance(value, (six.integer_types, six.string_types))):
Expand Down
4 changes: 2 additions & 2 deletions apitools/base/protorpclite/protojson_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -375,9 +375,9 @@ def testDecodeInvalidDateTime(self):

def testDecodeInvalidMessage(self):
encoded = """{
"a_nested_datetime": {
"a_nested_datetime": [{
"nested_dt_value": "invalid"
}
}]
}
"""
self.assertRaises(messages.DecodeError, protojson.decode_message,
Expand Down

0 comments on commit 139a079

Please sign in to comment.