Assuming envois
is a socket, you will not receive more than the amount you specify. From the docs
socket.recv(bufsize[, flags])
Receive data from the socket. The return value is a bytes object representing the data received. The maximum amount of data to be received at once is specified by bufsize.
You should be able to assert len(tuple) <= 7
But, don’t name a variable tuple
. You will hide the builtin.
solved why recv accept mort than expected number of bytes ? [closed]