Check if the return value is -1.  If so, goto fail, which will invoke PyErr_Ocurred().

https://docs.python.org/2/c-api/int.html
https://docs.python.org/2/c-api/float.html

Somehow runnning PyErr_Ocurred() when no exception has been generated triggers an unknown thread state and
seg faults.

Again, I noticed this issue when trying to pass in a Python dictionary with integer/double values and seg faults.