title: redirect_stderr does not work (Python 3.5)
body: <pre><code>#! python3
  from contextlib import redirect_stderr
  import io
  
  f = io.StringIO()
  with redirect_stderr(f):
      # simulates an error
      erd
  </code></pre>
  
  <p>As seen above, I have used the <code>redirect_stderr</code>  function to redirect stderr to a <code>StringIO</code> object. However, it doesn't work, as the error message is still printed out in command prompt:</p>
  
  <pre><code>Traceback (most recent call last):
    File "C:\Users\max\testerr.py", line 8, in &lt;module&gt;
      erd
  NameError: name 'erd' is not defined
  </code></pre>
  
  <p>I tested it on Python <code>3.5.1</code> 64 bit and <code>3.5.2</code> 64 bit with the same results. </p>
  
  <p><a href="https://stackoverflow.com/questions/33500220/python-how-to-redirect-stderr-to-a-file">A similar issue in this thread</a></p>
  
  <p>I have also tried writing the error to a file as described in the linked thread, but the file is empty after running the script.</p>