Issue #12996: multiprocessing.connection: transmit the header in network byte

order (endpoints machines can have different endianness).
parent 6fa67775
...@@ -422,7 +422,7 @@ class Connection(_ConnectionBase): ...@@ -422,7 +422,7 @@ class Connection(_ConnectionBase):
def _send_bytes(self, buf): def _send_bytes(self, buf):
# For wire compatibility with 3.2 and lower # For wire compatibility with 3.2 and lower
n = len(buf) n = len(buf)
self._send(struct.pack("=i", len(buf))) self._send(struct.pack("!i", n))
# The condition is necessary to avoid "broken pipe" errors # The condition is necessary to avoid "broken pipe" errors
# when sending a 0-length buffer if the other end closed the pipe. # when sending a 0-length buffer if the other end closed the pipe.
if n > 0: if n > 0:
...@@ -430,7 +430,7 @@ class Connection(_ConnectionBase): ...@@ -430,7 +430,7 @@ class Connection(_ConnectionBase):
def _recv_bytes(self, maxsize=None, sentinels=()): def _recv_bytes(self, maxsize=None, sentinels=()):
buf = self._recv(4, sentinels) buf = self._recv(4, sentinels)
size, = struct.unpack("=i", buf.getvalue()) size, = struct.unpack("!i", buf.getvalue())
if maxsize is not None and size > maxsize: if maxsize is not None and size > maxsize:
return None return None
return self._recv(size, sentinels) return self._recv(size, sentinels)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment