Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions botocore/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ def __init__(self, shape_name, shape_model, shape_resolver=None):
"""
self.name = shape_name
self.type_name = shape_model['type']
self.boxed = shape_model.get('box', False)
self.documentation = shape_model.get('documentation', '')
self._shape_model = shape_model
if shape_resolver is None:
Expand Down
17 changes: 17 additions & 0 deletions botocore/parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,15 @@ class ResponseParserError(Exception):
pass


def box_decorator(func):
def handle_box(self, shape, value):
if shape.boxed and value is None:
return None
return func(self, shape, value)

return handle_box


class ResponseParser:
"""Base class for response parsing.

Expand Down Expand Up @@ -340,10 +349,18 @@ def _do_modeled_error_parse(self, response, shape, parsed):
f"{self.__class__.__name__}._do_modeled_error_parse"
)

BOXABLE_PRIMITIVE_TYPES = ["long", "integer", "boolean"]

def _parse_shape(self, shape, node):
handler = getattr(
self, f'_handle_{shape.type_name}', self._default_handle
)
if (
shape.type_name in self.BOXABLE_PRIMITIVE_TYPES
and shape.boxed
and node is None
):
return None
return handler(shape, node)

def _handle_list(self, shape, node):
Expand Down