python / asyncio

asyncio historical repository
https://docs.python.org/3/library/asyncio.html
1.04k stars 177 forks source link

Fix ordering issues in UNIX read/write pipe transport constructors #408

Closed ronf closed 8 years ago

ronf commented 8 years ago

Here's a pull request designed to fix the issue reported in #368.

This commit re-orders the initialization code in the _UnixReadPipeTransport and _UnixWritePipeTransport constructors to make sure all members are assigned a value, even in the case where ValueError is raised due to an incompatible type of pipe. This avoids exceptions being raised in repr() due to the missing members.

In the case where ValueError is raised, this commit also clears the values of _pipe, _fileno, and _protocol since this transport isn't returned, avoiding a spurious "unclosed transport" warning when the object is garbage-collected.

asvetlov commented 8 years ago

Thank you, @ronf

ronf commented 8 years ago

Thank you!