title: PyCompileError exception is not being thrown for code with errors
body: <p>I can't seem to generate this exception with python code with a genuine error.</p>
  <p>I used the code from <a href="https://stackoverflow.com/questions/49554798/pycompileerror-exception">this question</a> to check my work.  Here it is, modified only slightly:</p>
  <pre><code>import py_compile
  
  def check(python_file):
      try:
          file = open(python_file, 'r')
          py_compile.compile(python_file, doraise=True)
  
      except py_compile.PyCompileError:
         print(&quot;&lt;&quot;+python_file+&quot;&gt; does not contain syntactically correct Python code&quot;)
     
      else:
         print(&quot;Compiled &quot; + python_file + &quot; with no issues.&quot;)
     
  check(&quot;example.py&quot;)
  </code></pre>
  <p>The file example.py contains just:</p>
  <pre><code>print (&quot;This is fine.&quot;)
  prant (&quot;This should be an error.&quot;)
  </code></pre>
  <p>'prant' instead of 'print' would be a simple syntax error, and if I run 'python example.py' then I see:</p>
  <pre><code>This is fine.
  Traceback (most recent call last):
    File &quot;example.py&quot;, line 2, in &lt;module&gt;
      prant (&quot;This should be an error.&quot;)
  NameError: name 'prant' is not defined
  </code></pre>
  <p>If I call the script at the top 'compiler.py' and then run 'python compiler.py' it will say there are no issues.</p>
  <p>I have verified that compiler.py will complain about syntactic correctness if there are unmatched parentheses or quotes, so it does catch <em>some</em> problems.  But I would like to be able to detect when a file has errors in the same way that running 'python example.py' or whatever would do.  Basically, if it has an error when running it with 'python', I'd like to be able to detect that.</p>
  <p>Is there a way to do this?  And why is PyCompileError not being thrown when there is a syntax error?</p>