check before calling PyObject_GetAttrString(): this throws an exception.