bpo-30861: Return StreamReeader remaining buffer before raise excepiton by pfreixes · Pull Request #2593 · python/cpython (original) (raw)

The current implementation of StreamReader does not take care of the status of the buffer, once an exception has been set via set_exception any call to the read methods won't be able to get the missing data still pending to be processed.

From the point of view of the developer, if there is no scheduled task for waiting for data into the Streamreader between a network data gets into the buffer socket and a closing connection by the other peer arrives, the developer won't be able to gather the previous data.

This PR take care first of the remaining buffer and try to return first to the user, and only when the buffer has run out raises the proper exception