title: Python script exits with exit code 255 despite try-except block
body: <p>I am trying to build some exception handling into my Script before sending it out to users trial. To achieve this I'm trying to run <code>try-except</code> blocks to catch errors where I think they're likely to occur.</p>
  
  <p>For example, the code uses an API to interact with another piece of software. This software relies on a hardware licence (USB dongle) to be installed in teh computer, otherwise the software cannot be accessed by Python and the script exits with Exit Code 255. Code example below.</p>
  
  <pre><code>    code-to-activate-licence
  except Exception as e:
       warn-user-of-error
  </code></pre>
  
  <p>I would expect the <code>try-except</code> block to pick up the exit code and execute the <code>except</code> portion of the code. However, I assume that as the attempt to activate the licence does not seem to raise an error but instead gives a non-zero exit code it doesn't seem to be caught by the <code>try-except</code> block. Is there a way to catch this exit code before it actually exits the script?</p>