title: Popen.stderr.readline hangs if the stderr string is not terminated with '\n'
body: <p>I have the below script b.py</p>
  
  <pre><code>import sys
  sym = "NEW WORD"
  print &gt;&gt; sys.stderr, "You must enter a single word.\n"
  sys.stderr.write(("Please enter the correct word for %s\n"
                    "Or enter 'n' if it is not correct: ") % sym)
  sym = raw_input()         
  sys.stderr.write(("Please enter the correct word for %s\n"
                    "Or enter 'n' if it is not correct: ") % sym)
  </code></pre>
  
  <p>I am trying to run this script using Popen where I am facing the issue. That is, after reading few lines, it gets stuck. The same works (no hanging) if I have a '\n' appended to the statement after <code>correct:</code> otherwise not.</p>
  
  <pre><code>cmd2 = ['python', 'b.py']
  In [43]: p =  Popen(cmd2 , stdin=PIPE, stdout=PIPE, stderr=PIPE, universal_newlines=True)
  In [44]: p.stderr.readline()
  Out[44]: 'You must enter a single word.\n'
  In [45]: p.stderr.readline()
  Out[45]: '\n'
  In [46]: p.stderr.readline()
  Out[46]: 'Please enter the correct word for NEW WORD\n'
  In [47]: p.stderr.readline()
  &lt;Hangs&gt;
  </code></pre>
  
  <p>Why is this happening so ? Also is there any solution for this (apart from making any changes to b.py)</p>
  
  <p>But things work fine when I run the script b.py manually</p>
  
  <pre><code>python b.py
  You must enter a single word.
  
  Please enter the correct word for NEW WORD
  Or enter 'n' if it is not correct: HELLO
  Please enter the correct word for HELLO
  Or enter 'n' if it is not correct: 
  </code></pre>