[Bug 352073] Re: python-pexpect just duplicates stdin

Thomas Kluyver 352073 at bugs.launchpad.net
Sat Nov 2 18:14:16 UTC 2013


This may seem weird, but echoing stdin is part of how tty devices work.
That's why you see what you're typing at a terminal. The output is
printed on the next line, but your Python script only reads one line, so
it doesn't see it.

You can disable tty echo with the setecho method:
http://pexpect.readthedocs.org/en/latest/api/pexpect.html#pexpect.spawn.setecho

** Changed in: pexpect (Ubuntu)
       Status: New => Invalid

-- 
You received this bug notification because you are a member of Ubuntu
Foundations Bugs, which is subscribed to pexpect in Ubuntu.
https://bugs.launchpad.net/bugs/352073

Title:
  python-pexpect just duplicates stdin

Status in “pexpect” package in Ubuntu:
  Invalid

Bug description:
  [0] nokile:~/nobackup$ cat test.pl
  #!/usr/bin/perl
  #
  while (<>) {
      s/[0-9]+/__/g;
      print;
  }
  [0] nokile:~/nobackup$ echo bla24fasel | ./test.pl
  bla__fasel
  [0] nokile:~/nobackup$ cat test.py
  #!/usr/bin/python

  import pexpect

  child = pexpect.spawn("./test.pl")

  while True:
      try:
          line = raw_input()
      except EOFError:
          break

      child.sendline(line)
      print child.readline().rstrip("\r\n")

  child.close()
  [0] nokile:~/nobackup$ echo bla24fasel | ./test.py
  bla24fasel
  [0] nokile:~/nobackup$ 

  I expected the last outpout to be bla__fasel, as it is returned by the
  child.

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/pexpect/+bug/352073/+subscriptions



More information about the foundations-bugs mailing list