in src/aws_encryption_sdk/internal/utils/streams.py [0:0]
def read(self, b=-1):
"""Keep reading from source stream until either the source stream is done
or the requested number of bytes have been obtained.
:param int b: number of bytes to read
:return: All bytes read from wrapped stream
:rtype: bytes
"""
remaining_bytes = b
data = io.BytesIO()
while True:
try:
chunk = to_bytes(self.__wrapped__.read(remaining_bytes))
except ValueError:
if self.__wrapped__.closed:
break
raise
if not chunk:
break
data.write(chunk)
remaining_bytes -= len(chunk)
if remaining_bytes <= 0:
break
return data.getvalue()