]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Issue #12996: multiprocessing.connection: transmit the header in network byte
authorCharles-François Natali <neologix@free.fr>
Tue, 20 Sep 2011 17:27:39 +0000 (19:27 +0200)
committerCharles-François Natali <neologix@free.fr>
Tue, 20 Sep 2011 17:27:39 +0000 (19:27 +0200)
order (endpoints machines can have different endianness).

Lib/multiprocessing/connection.py

index ae2d135e034b6c1db5808564cd10738c7f9231c8..13d3d777f2ece3cdb7c86708ec432e9e7551af73 100644 (file)
@@ -422,7 +422,7 @@ class Connection(_ConnectionBase):
     def _send_bytes(self, buf):
         # For wire compatibility with 3.2 and lower
         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
         # when sending a 0-length buffer if the other end closed the pipe.
         if n > 0:
@@ -430,7 +430,7 @@ class Connection(_ConnectionBase):
 
     def _recv_bytes(self, maxsize=None, 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:
             return None
         return self._recv(size, sentinels)