You assume you are readdoing something that is not there. As its documentation says:
read(...)
read([size]) -> read at most size bytes, returned as a string.
it reads no more than size bytes
If you need exactly a sizebyte, you need to create a wrapper function.
Here is an example (not fully tested) that you can adapt:
def read_exactly( fd, size ):
data=""
remaining= size
while remaining>0:
newdata= fd.read(remaining)
if len(newdata)==0:
raise IOError("Failed to read enough data")
data+=newdata
remaining-= len(newdata)
return data
, Windows, , - read () .