Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 225aa4f

Browse files
author
Charles-François Natali
committed
Issue #12996: multiprocessing.connection: transmit the header in network byte
order (endpoints machines can have different endianness).
1 parent 6fa6777 commit 225aa4f

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

Lib/multiprocessing/connection.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -422,15 +422,15 @@ def _recv(self, size, sentinels=(), read=_read):
422422
def _send_bytes(self, buf):
423423
# For wire compatibility with 3.2 and lower
424424
n = len(buf)
425-
self._send(struct.pack("=i", len(buf)))
425+
self._send(struct.pack("!i", n))
426426
# The condition is necessary to avoid "broken pipe" errors
427427
# when sending a 0-length buffer if the other end closed the pipe.
428428
if n > 0:
429429
self._send(buf)
430430

431431
def _recv_bytes(self, maxsize=None, sentinels=()):
432432
buf = self._recv(4, sentinels)
433-
size, = struct.unpack("=i", buf.getvalue())
433+
size, = struct.unpack("!i", buf.getvalue())
434434
if maxsize is not None and size > maxsize:
435435
return None
436436
return self._recv(size, sentinels)

0 commit comments

Comments
 (0)