Skip to content

Commit 504d08b

Browse files
committed
normalize read() parameter value to correctly always be an int
1 parent 7013f40 commit 504d08b

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/aws_encryption_sdk/streaming_client.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -202,16 +202,16 @@ def readable(self):
202202
# Open streams are currently always readable.
203203
return not self.closed
204204

205-
def read(self, b=None):
205+
def read(self, b=-1):
206206
"""Returns either the requested number of bytes or the entire stream.
207207
208208
:param int b: Number of bytes to read
209209
:returns: Processed (encrypted or decrypted) bytes from source stream
210210
:rtype: bytes
211211
"""
212-
# Any negative value for b is interpreted as a full read
213-
if b is not None and b < 0:
214-
b = None
212+
# NoneType value for b is interpretted as a full read for legacy compatibility
213+
if b is None:
214+
b = -1
215215

216216
_LOGGER.debug("Stream read called, requesting %s bytes", b)
217217
output = io.BytesIO()

0 commit comments

Comments
 (0)