title: How do I handle this buggy program in pexpect?
body: <p>I use pexpect to automate a program called instantmusic. Sometimes, this program sends an eof before it has actually finished. Here is a screenshot (If you can’t read the screenshot, I have linked to my more detailed bug report at the end of the question.):
  <a href="https://i.stack.imgur.com/Ig5mO.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Ig5mO.jpg" alt="enter image description here"></a></p>
  
  <p>I can detect the appropriate ending by using this code:</p>
  
  <pre><code>child.expect(
          ['Deleting*(pass -k to keep)*', pexpect.EOF], timeout=3000)
  </code></pre>
  
  <p>However, my problem is that pexpect doesn’t catch the output beyond the eof. (Btw, not using that “pexpect.EOF” makes pexpect throw an exception when it encounters EOF.)</p>
  
  <p>Is there a way to handle this problem?</p>
  
  <p>PS: I have described this bug in more detail <a href="https://github.com/yask123/Instant-Music-Downloader/issues/135" rel="nofollow noreferrer">here</a>. But I generally like to be able to handle this situation even if the source program IS buggy. Since it seems to me that it should be possible.</p>