When a Python string fails in an expected way, we need to be able to
check that it raised the exception we were expecting. This combined
with the parser check implemented recently gives way better Python
testing.
This function distinguishes between expected runtime errors, and errors caused
by bad code in the given string. Parse errors and related problems should
always result in the test failing. Expected runtime errors are necessary to
fully cover pathways in the Python bindings.