Tell Python includes we have threads and fix up the resulting issues

I was surprised that Py_BEGIN_ALLOW_THREADS was working, but it turns
out that we weren't enabling threading so it wasn't doing anything.