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
15 changes: 11 additions & 4 deletions eth_abi/decoding.py
Original file line number Diff line number Diff line change
Expand Up @@ -386,10 +386,17 @@ def read_data_from_stream(self, stream):
data = stream.read(self.data_byte_size)

if len(data) != self.data_byte_size:
raise InsufficientDataBytes(
f"Tried to read {self.data_byte_size} bytes, "
f"only got {len(data)} bytes."
)
if self.strict:
raise InsufficientDataBytes(
f"Tried to read {self.data_byte_size} bytes, "
f"only got {len(data)} bytes."
)

# Pad the value.
data_stripped = data.lstrip(b"\x00")
num_zeroes = max(0, 32 - len(data_stripped))
zeroes = b"\x00" * num_zeroes
data = zeroes + data_stripped

return data

Expand Down
8 changes: 1 addition & 7 deletions eth_abi/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -474,13 +474,7 @@ def has_encoder(self, type_str: abi.TypeStr) -> bool:

def _get_decoder_uncached(self, type_str, strict=True):
decoder = self._get_registration(self._decoders, type_str)

if hasattr(decoder, "is_dynamic") and decoder.is_dynamic:
# Set a transient flag each time a call is made to ``get_decoder()``.
# Only dynamic decoders should be allowed these looser constraints. All
# other decoders should keep the default value of ``True``.
decoder.strict = strict

decoder.strict = strict
return decoder

def copy(self):
Expand Down