-
-
Notifications
You must be signed in to change notification settings - Fork 178
Fix ordering issues in UNIX read/write pipe transport constructors #370
Conversation
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.
Sorry - I accidentally checked in a proposed fix to issue #369 into this same pull request. I should have used a separate branch for that. Let me know if you'd like me to split them. |
Hi Ron,
Yes, please split them. That will make the review easier. |
The git-level fix should be easy right? `git reset HEAD^; git push -f`
|
Thanks - done. I'll submit the other patch in a separate pull request. |
Should we add a unittest checking that the repr works after a ValueError? |
This is a bit tricky to do as a black-box test, as the object is not returned to the caller when a ValueError is raised, so there's nothing to call repr on from within the unit test code. |
…#387) Signed-off-by: Sorin Sbarnea <sorin.sbarnea@gmail.com>
…python#374) * Don't select for read on character devices in _UnixWritePipeTransport _UnixWritePipeTransport selects for read on write pipes to detect when the remote end of the pipe is closed. This works for unidirectional FIFOs and dedicated socket pairs where nothing is written to the read side of the pair, but it can cause problems with devices or sockets where bidirectional I/O is being done. This commit changes _UnixWritePipeTransport to only select for read on sockets and FIFOs (on OSes which support that), and not on character devices. When connect_write_pipe() is used on those devices, end-of-file will need to be detected using a read pipe which accepts inputs from the device. No change is made to how sockets are handled, so passing in a socket used for bidirectional I/O to connect_write_pipe() is not supported. Async I/O on sockets should be performed using functions like BaseEventLoop.create_connection(). Socket pairs which are only used for undirectional I/O can be used here, though. * Add new unit test for bidirectional I/O on TTYs * Don't import tty module on Windows While the Windows release of Python seems to include the 'tty' module, attempting to import it fails with an error about not finding the 'termios' module. Since the tty tests here aren't run on Windows, though, there's no need to import tty there. This commit makes the import conditional on the platform.
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.