def handle_stdin(self, input_, output, echo):
        with character_buffered(input_):
            while True:
                byte = None
                if ready_for_reading(input_):
                    # Read 1 byte at a time for interactivity's sake.
                    byte = read_byte(input_)
                    # When reading from file-like objects that aren't "real"
                    # terminal streams, an empty byte signals EOF.
                    if not byte:
                        break
                    # Mirror what we just read to process' stdin.
                    # We perform an encode so Python 3 gets bytes (streams +
                    # str's in Python 3 == no bueno) but skip the decode step,
                    # since there's presumably no need (nobody's interacting
                    # with this data programmatically).
                    # TODO: consider baking the encode call into write_stdin
                    # (needs indirection as actual impl of write_stdin differs
                    # between subclasses...)
                    # TODO: will this break with multibyte input character
                    # encoding?
                    self.write_stdin(self.encode(byte))
                    # Also echo it back to local stdout (or whatever
                    # out_stream is set to) when necessary.
                    if echo is None:
                        echo = self.echo_stdin(input_, output)
                    if echo:
                        output.write(byte) # TODO: encode?
                        output.flush()
                # Dual all-done signals: program being executed is done
                # running, *and* we don't seem to be reading anything out of
                # stdin. (If we only test the former, we may encounter race
                # conditions re: unread stdin.)
                if self.program_finished.is_set() and not byte:
                    break
                # Take a nap so we're not chewing CPU.
                time.sleep(self.input_sleep)

        # while not self.program_finished.is_set():
        #    # TODO: reinstate lock/whatever thread logic from fab v1 which
        #    # prevents reading from stdin while other parts of the code are
        #    # prompting for runtime passwords? (search for 'input_enabled')
        #    if have_char and chan.input_enabled:
        #        # Send all local stdin to remote end's stdin
        #        #byte = msvcrt.getch() if WINDOWS else sys.stdin.read(1)
        #        yield self.encode(sys.stdin.read(1))
        #        # Optionally echo locally, if needed.
        #        # TODO: how to truly do this? access the out_stream which
        #        # isn't currently visible to us? if we just skip this part,
        #        # interactive users may not have their input echoed...ISTR we
        #        # used to assume remote would send it back down stdout/err...
        #        # clearly not?
        #        #if not using_pty and env.echo_stdin:
        #            # Not using fastprint() here -- it prints as 'user'
        #            # output level, don't want it to be accidentally hidden
        #        #    sys.stdout.write(byte)
        #        #    sys.stdout.flush()
Test whether an interface is in the specification
dataset/ETHPy150Open pyinvoke/invoke/invoke/runners.py/Runner.handle_stdin--crossover with--dataset/ETHPy150Open nlloyd/SubliminalCollaborator/libs/zope/interface/declarations.py/Declaration.__contains__