code refactor. removed the explicit throwing of exceptions and wrap
PyObject* to avoid manual reference counting