Skip to content

Commit 1dae12f

Browse files
committed
Cast view to bytes, fix typo
Signed-off-by: Christian Heimes <[email protected]>
1 parent 9c3d0e6 commit 1dae12f

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

Lib/ssl.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -959,12 +959,12 @@ def sendall(self, data, flags=0):
959959
raise ValueError(
960960
"non-zero flags not allowed in calls to sendall() on %s" %
961961
self.__class__)
962-
amount = len(data)
963962
count = 0
964-
view = memoryview(data)
965-
while (count < amount):
966-
v = self.send(view[count:])
967-
count += v
963+
with memoryview(data) as view, view.cast("B") as byte_view:
964+
amount = len(byte_view)
965+
while count < amount:
966+
v = self.send(byte_view[count:])
967+
count += v
968968
else:
969969
return socket.sendall(self, data, flags)
970970

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
SSLSocket.sendall() now uses memoryview to create slices of data. This fix
1+
SSLSocket.sendall() now uses memoryview to create slices of data. This fixes
22
support for all bytes-like object. It is also more efficient and avoids
33
costly copies.

0 commit comments

Comments
 (0)