-
Type: Improvement
-
Resolution: Done
-
Priority: Major - P3
-
Affects Version/s: 2.0
-
Component/s: None
-
None
-
Fully Compatible
Function _closed(sock) uses sock.recv() without parameters, which always raises a TypeError and thus if there's data in the socket it will return True anyway. This patch removes the call to sock.recv() because it is not needed, what's worse is that would it ever succeed some data would be removed from the socket and its state would become inconsistent.
So the only check needed is to check if len(rd) is non-zero, because if it is the socket is either closed or has unexpected data, in either case it cannot be used safely.