diff options
author | Campbell Barton <ideasman42@gmail.com> | 2009-04-20 01:01:12 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2009-04-20 01:01:12 +0400 |
commit | f5fc4ebdd8ede5263f4b34f161ebe139d40466dc (patch) | |
tree | 7122404f3410c14cd225343cfc97bc0a97441f1e /source | |
parent | d78eec93197cc1d3cc9da773ce30396891ec60f6 (diff) |
BGE Python API
- More verbose error messages.
- BL_Shader wasnt setting error messages on some errors
- FilterNormal depth attribute was checking for float which is bad because scripts often expect ints assigned to float attributes.
- Added a check to PyVecTo for a tuple rather then always using a generic python sequence. On my system this is over 2x faster with an optmized build.
Diffstat (limited to 'source')
30 files changed, 285 insertions, 233 deletions
diff --git a/source/gameengine/Converter/BL_ActionActuator.cpp b/source/gameengine/Converter/BL_ActionActuator.cpp index f413ad969f4..7515f3f5f91 100644 --- a/source/gameengine/Converter/BL_ActionActuator.cpp +++ b/source/gameengine/Converter/BL_ActionActuator.cpp @@ -1037,7 +1037,7 @@ int BL_ActionActuator::pyattr_set_action(void *self_v, const KX_PYATTRIBUTE_DEF if (!PyString_Check(value)) { - PyErr_SetString(PyExc_ValueError, "expected the string name of the action"); + PyErr_SetString(PyExc_ValueError, "actuator.action = val: Action Actuator, expected the string name of the action"); return -1; } @@ -1049,7 +1049,7 @@ int BL_ActionActuator::pyattr_set_action(void *self_v, const KX_PYATTRIBUTE_DEF action= (bAction*)SCA_ILogicBrick::m_sCurrentLogicManager->GetActionByName(val); if (!action) { - PyErr_SetString(PyExc_ValueError, "action not found!"); + PyErr_SetString(PyExc_ValueError, "actuator.action = val: Action Actuator, action not found!"); return 1; } } diff --git a/source/gameengine/Converter/BL_ActionActuator.h b/source/gameengine/Converter/BL_ActionActuator.h index d5b5762d9e7..6ae7f716b4b 100644 --- a/source/gameengine/Converter/BL_ActionActuator.h +++ b/source/gameengine/Converter/BL_ActionActuator.h @@ -154,7 +154,7 @@ public: case ACT_ACTION_FROM_PROP: return 0; default: - PyErr_SetString(PyExc_ValueError, "invalid type supplied"); + PyErr_SetString(PyExc_ValueError, "Action Actuator, invalid play type supplied"); return 1; } } diff --git a/source/gameengine/Converter/BL_ShapeActionActuator.cpp b/source/gameengine/Converter/BL_ShapeActionActuator.cpp index 25a4413a31d..62bc99bb437 100644 --- a/source/gameengine/Converter/BL_ShapeActionActuator.cpp +++ b/source/gameengine/Converter/BL_ShapeActionActuator.cpp @@ -869,7 +869,7 @@ int BL_ShapeActionActuator::pyattr_set_action(void *self_v, const KX_PYATTRIBUTE /* exact copy of BL_ActionActuator's function from here down */ if (!PyString_Check(value)) { - PyErr_SetString(PyExc_ValueError, "expected the string name of the action"); + PyErr_SetString(PyExc_ValueError, "actuator.action = val: Shape Action Actuator, expected the string name of the action"); return -1; } @@ -881,7 +881,7 @@ int BL_ShapeActionActuator::pyattr_set_action(void *self_v, const KX_PYATTRIBUTE action= (bAction*)SCA_ILogicBrick::m_sCurrentLogicManager->GetActionByName(val); if (action==NULL) { - PyErr_SetString(PyExc_ValueError, "action not found!"); + PyErr_SetString(PyExc_ValueError, "actuator.action = val: Shape Action Actuator, action not found!"); return 1; } } diff --git a/source/gameengine/Converter/BL_ShapeActionActuator.h b/source/gameengine/Converter/BL_ShapeActionActuator.h index 716d8c9995b..3bc35ac9495 100644 --- a/source/gameengine/Converter/BL_ShapeActionActuator.h +++ b/source/gameengine/Converter/BL_ShapeActionActuator.h @@ -144,7 +144,7 @@ public: case ACT_ACTION_FROM_PROP: return 0; default: - PyErr_SetString(PyExc_ValueError, "invalid type supplied"); + PyErr_SetString(PyExc_ValueError, "Shape Action Actuator, invalid play type supplied"); return 1; } diff --git a/source/gameengine/Expressions/ListValue.cpp b/source/gameengine/Expressions/ListValue.cpp index 5c7e6a4383e..dd9b296dce1 100644 --- a/source/gameengine/Expressions/ListValue.cpp +++ b/source/gameengine/Expressions/ListValue.cpp @@ -58,7 +58,7 @@ PyObject* listvalue_buffer_item(PyObject* self, Py_ssize_t index) return list->GetValue(index)->GetProxy(); } - PyErr_SetString(PyExc_IndexError, "Python ListIndex out of range"); + PyErr_SetString(PyExc_IndexError, "list[i]: Python ListIndex out of range in CValueList"); return NULL; } @@ -85,7 +85,7 @@ PyObject* listvalue_mapping_subscript(PyObject* self, PyObject* pyindex) } PyObject *pyindex_str = PyObject_Repr(pyindex); /* new ref */ - PyErr_Format(PyExc_KeyError, "'%s' not in list", PyString_AsString(pyindex_str)); + PyErr_Format(PyExc_KeyError, "list[key]: '%s' key not in list", PyString_AsString(pyindex_str)); Py_DECREF(pyindex_str); return NULL; } @@ -162,7 +162,7 @@ listvalue_buffer_concat(PyObject * self, PyObject * other) } if (error) { - PyErr_SetString(PyExc_SystemError, "Python Error: couldn't add one or more items to a list"); + PyErr_SetString(PyExc_SystemError, "list.append(val): couldn't add one or more items to this CValueList"); return NULL; } @@ -187,7 +187,7 @@ listvalue_buffer_concat(PyObject * self, PyObject * other) listval->Add(objval); } else { - PyErr_SetString(PyExc_SystemError, "Python Error: couldn't add item to a list"); + PyErr_SetString(PyExc_SystemError, "list.append(i): couldn't add item to this CValueList"); return NULL; } } @@ -495,7 +495,7 @@ PyObject* CListValue::Pyindex(PyObject *value) checkobj->Release(); if (result==NULL) { - PyErr_SetString(PyExc_ValueError, "ValueError: list.index(x): x not in CListValue"); + PyErr_SetString(PyExc_ValueError, "list.index(x): x not in CListValue"); } return result; @@ -543,7 +543,7 @@ PyObject* CListValue::Pyfrom_id(PyObject* value) if (reinterpret_cast<uintptr_t>(m_pValueArray[i]->m_proxy) == id) return GetValue(i)->GetProxy(); } - PyErr_SetString(PyExc_IndexError, "from_id(#), id not found in CValueList"); + PyErr_SetString(PyExc_IndexError, "from_id(#): id not found in CValueList"); return NULL; } diff --git a/source/gameengine/Expressions/PyObjectPlus.cpp b/source/gameengine/Expressions/PyObjectPlus.cpp index da761bd22cb..6cfa14ddc80 100644 --- a/source/gameengine/Expressions/PyObjectPlus.cpp +++ b/source/gameengine/Expressions/PyObjectPlus.cpp @@ -325,12 +325,12 @@ int PyObjectPlus::py_set_attrdef(void *self, const PyAttributeDef *attrdef, PyOb { if (!PySequence_Check(value)) { - PyErr_SetString(PyExc_TypeError, "expected a sequence"); + PyErr_Format(PyExc_TypeError, "expected a sequence for attribute \"%s\"", attrdef->m_name); return 1; } if (PySequence_Size(value) != attrdef->m_length) { - PyErr_SetString(PyExc_TypeError, "incorrect number of elements in sequence"); + PyErr_Format(PyExc_TypeError, "incorrect number of elements in sequence for attribute \"%s\"", attrdef->m_name); return 1; } switch (attrdef->m_type) @@ -338,7 +338,7 @@ int PyObjectPlus::py_set_attrdef(void *self, const PyAttributeDef *attrdef, PyOb case KX_PYATTRIBUTE_TYPE_FUNCTION: if (attrdef->m_setFunction == NULL) { - PyErr_SetString(PyExc_AttributeError, "function attribute without function, report to blender.org"); + PyErr_Format(PyExc_AttributeError, "function attribute without function for attribute \"%s\", report to blender.org", attrdef->m_name); return 1; } return (*attrdef->m_setFunction)(self, attrdef, value); @@ -357,7 +357,7 @@ int PyObjectPlus::py_set_attrdef(void *self, const PyAttributeDef *attrdef, PyOb break; default: // should not happen - PyErr_SetString(PyExc_AttributeError, "Unsupported attribute type, report to blender.org"); + PyErr_Format(PyExc_AttributeError, "Unsupported attribute type for attribute \"%s\", report to blender.org", attrdef->m_name); return 1; } // let's implement a smart undo method @@ -390,7 +390,7 @@ int PyObjectPlus::py_set_attrdef(void *self, const PyAttributeDef *attrdef, PyOb } else { - PyErr_SetString(PyExc_TypeError, "expected an integer or a bool"); + PyErr_Format(PyExc_TypeError, "expected an integer or a bool for attribute \"%s\"", attrdef->m_name); goto UNDO_AND_ERROR; } break; @@ -411,14 +411,14 @@ int PyObjectPlus::py_set_attrdef(void *self, const PyAttributeDef *attrdef, PyOb } else if (val < attrdef->m_imin || val > attrdef->m_imax) { - PyErr_SetString(PyExc_ValueError, "item value out of range"); + PyErr_Format(PyExc_ValueError, "item value out of range for attribute \"%s\"", attrdef->m_name); goto UNDO_AND_ERROR; } *var = (short int)val; } else { - PyErr_SetString(PyExc_TypeError, "expected an integer"); + PyErr_Format(PyExc_TypeError, "expected an integer for attribute \"%s\"", attrdef->m_name); goto UNDO_AND_ERROR; } break; @@ -427,7 +427,7 @@ int PyObjectPlus::py_set_attrdef(void *self, const PyAttributeDef *attrdef, PyOb // enum are equivalent to int, just make sure that the field size matches: if (sizeof(int) != attrdef->m_size) { - PyErr_SetString(PyExc_AttributeError, "attribute size check error, report to blender.org"); + PyErr_Format(PyExc_AttributeError, "Size check error for attribute, \"%s\", report to blender.org", attrdef->m_name); goto UNDO_AND_ERROR; } // walkthrough @@ -447,14 +447,14 @@ int PyObjectPlus::py_set_attrdef(void *self, const PyAttributeDef *attrdef, PyOb } else if (val < attrdef->m_imin || val > attrdef->m_imax) { - PyErr_SetString(PyExc_ValueError, "item value out of range"); + PyErr_Format(PyExc_ValueError, "item value out of range for attribute \"%s\"", attrdef->m_name); goto UNDO_AND_ERROR; } *var = (int)val; } else { - PyErr_SetString(PyExc_TypeError, "expected an integer"); + PyErr_Format(PyExc_TypeError, "expected an integer for attribute \"%s\"", attrdef->m_name); goto UNDO_AND_ERROR; } break; @@ -466,7 +466,7 @@ int PyObjectPlus::py_set_attrdef(void *self, const PyAttributeDef *attrdef, PyOb double val = PyFloat_AsDouble(item); if (val == -1.0 && PyErr_Occurred()) { - PyErr_SetString(PyExc_TypeError, "expected a float"); + PyErr_Format(PyExc_TypeError, "expected a float for attribute \"%s\"", attrdef->m_name); goto UNDO_AND_ERROR; } else if (attrdef->m_clamp) @@ -478,7 +478,7 @@ int PyObjectPlus::py_set_attrdef(void *self, const PyAttributeDef *attrdef, PyOb } else if (val < attrdef->m_fmin || val > attrdef->m_fmax) { - PyErr_SetString(PyExc_ValueError, "item value out of range"); + PyErr_Format(PyExc_ValueError, "item value out of range for attribute \"%s\"", attrdef->m_name); goto UNDO_AND_ERROR; } *var = (float)val; @@ -486,7 +486,7 @@ int PyObjectPlus::py_set_attrdef(void *self, const PyAttributeDef *attrdef, PyOb } default: // should not happen - PyErr_SetString(PyExc_AttributeError, "attribute type check error, report to blender.org"); + PyErr_Format(PyExc_AttributeError, "type check error for attribute \"%s\", report to blender.org", attrdef->m_name); goto UNDO_AND_ERROR; } } @@ -515,7 +515,7 @@ int PyObjectPlus::py_set_attrdef(void *self, const PyAttributeDef *attrdef, PyOb { if (attrdef->m_setFunction == NULL) { - PyErr_SetString(PyExc_AttributeError, "function attribute without function, report to blender.org"); + PyErr_Format(PyExc_AttributeError, "function attribute without function \"%s\", report to blender.org", attrdef->m_name); return 1; } return (*attrdef->m_setFunction)(self, attrdef, value); @@ -545,7 +545,7 @@ int PyObjectPlus::py_set_attrdef(void *self, const PyAttributeDef *attrdef, PyOb bufferSize = strlen(reinterpret_cast<char*>(sourceBuffer))+1; break; default: - PyErr_SetString(PyExc_AttributeError, "unknown attribute type, report to blender.org"); + PyErr_Format(PyExc_AttributeError, "unknown type for attribute \"%s\", report to blender.org", attrdef->m_name); return 1; } if (bufferSize) @@ -573,7 +573,7 @@ int PyObjectPlus::py_set_attrdef(void *self, const PyAttributeDef *attrdef, PyOb } else { - PyErr_SetString(PyExc_TypeError, "expected an integer or a bool"); + PyErr_Format(PyExc_TypeError, "expected an integer or a bool for attribute \"%s\"", attrdef->m_name); goto FREE_AND_ERROR; } break; @@ -593,14 +593,14 @@ int PyObjectPlus::py_set_attrdef(void *self, const PyAttributeDef *attrdef, PyOb } else if (val < attrdef->m_imin || val > attrdef->m_imax) { - PyErr_SetString(PyExc_ValueError, "value out of range"); + PyErr_Format(PyExc_ValueError, "value out of range for attribute \"%s\"", attrdef->m_name); goto FREE_AND_ERROR; } *var = (short int)val; } else { - PyErr_SetString(PyExc_TypeError, "expected an integer"); + PyErr_Format(PyExc_TypeError, "expected an integer for attribute \"%s\"", attrdef->m_name); goto FREE_AND_ERROR; } break; @@ -609,7 +609,7 @@ int PyObjectPlus::py_set_attrdef(void *self, const PyAttributeDef *attrdef, PyOb // enum are equivalent to int, just make sure that the field size matches: if (sizeof(int) != attrdef->m_size) { - PyErr_SetString(PyExc_AttributeError, "attribute size check error, report to blender.org"); + PyErr_Format(PyExc_AttributeError, "attribute size check error for attribute \"%s\", report to blender.org", attrdef->m_name); goto FREE_AND_ERROR; } // walkthrough @@ -628,14 +628,14 @@ int PyObjectPlus::py_set_attrdef(void *self, const PyAttributeDef *attrdef, PyOb } else if (val < attrdef->m_imin || val > attrdef->m_imax) { - PyErr_SetString(PyExc_ValueError, "value out of range"); + PyErr_Format(PyExc_ValueError, "value out of range for attribute \"%s\"", attrdef->m_name); goto FREE_AND_ERROR; } *var = (int)val; } else { - PyErr_SetString(PyExc_TypeError, "expected an integer"); + PyErr_Format(PyExc_TypeError, "expected an integer for attribute \"%s\"", attrdef->m_name); goto FREE_AND_ERROR; } break; @@ -646,7 +646,7 @@ int PyObjectPlus::py_set_attrdef(void *self, const PyAttributeDef *attrdef, PyOb double val = PyFloat_AsDouble(value); if (val == -1.0 && PyErr_Occurred()) { - PyErr_SetString(PyExc_TypeError, "expected a float"); + PyErr_Format(PyExc_TypeError, "expected a float for attribute \"%s\"", attrdef->m_name); goto FREE_AND_ERROR; } else if (attrdef->m_clamp) @@ -658,7 +658,7 @@ int PyObjectPlus::py_set_attrdef(void *self, const PyAttributeDef *attrdef, PyOb } else if (val < attrdef->m_fmin || val > attrdef->m_fmax) { - PyErr_SetString(PyExc_ValueError, "value out of range"); + PyErr_Format(PyExc_ValueError, "value out of range for attribute \"%s\"", attrdef->m_name); goto FREE_AND_ERROR; } *var = (float)val; @@ -675,7 +675,7 @@ int PyObjectPlus::py_set_attrdef(void *self, const PyAttributeDef *attrdef, PyOb if (strlen(val) < attrdef->m_imin) { // can't increase the length of the string - PyErr_SetString(PyExc_ValueError, "string length too short"); + PyErr_Format(PyExc_ValueError, "string length too short for attribute \"%s\"", attrdef->m_name); goto FREE_AND_ERROR; } else if (strlen(val) > attrdef->m_imax) @@ -689,21 +689,21 @@ int PyObjectPlus::py_set_attrdef(void *self, const PyAttributeDef *attrdef, PyOb } } else if (strlen(val) < attrdef->m_imin || strlen(val) > attrdef->m_imax) { - PyErr_SetString(PyExc_ValueError, "string length out of range"); + PyErr_Format(PyExc_ValueError, "string length out of range for attribute \"%s\"", attrdef->m_name); goto FREE_AND_ERROR; } *var = val; } else { - PyErr_SetString(PyExc_TypeError, "expected a string"); + PyErr_Format(PyExc_TypeError, "expected a string for attribute \"%s\"", attrdef->m_name); goto FREE_AND_ERROR; } break; } default: // should not happen - PyErr_SetString(PyExc_AttributeError, "unknown attribute type, report to blender.org"); + PyErr_Format(PyExc_AttributeError, "unknown type for attribute \"%s\", report to blender.org", attrdef->m_name); goto FREE_AND_ERROR; } } @@ -787,7 +787,7 @@ PyObject *PyObjectPlus::PyisA(PyObject *value) // Python wrapper for isA } else if (PyString_Check(value)) { return PyBool_FromLong(isA(PyString_AsString(value))); } - PyErr_SetString(PyExc_TypeError, "expected a type or a string"); + PyErr_SetString(PyExc_TypeError, "object.isA(value): expected a type or a string"); return NULL; } diff --git a/source/gameengine/Expressions/Value.cpp b/source/gameengine/Expressions/Value.cpp index ca46d782992..7cb97909119 100644 --- a/source/gameengine/Expressions/Value.cpp +++ b/source/gameengine/Expressions/Value.cpp @@ -671,7 +671,7 @@ CValue* CValue::ConvertPythonToValue(PyObject* pyobj) } else { /* return an error value from the caller */ - PyErr_SetString(PyExc_TypeError, "This python value could not be assigned to a game engine property"); + PyErr_SetString(PyExc_TypeError, "This python type could not be converted to a to a game engine property"); } return vallie; diff --git a/source/gameengine/GameLogic/SCA_JoystickSensor.cpp b/source/gameengine/GameLogic/SCA_JoystickSensor.cpp index 28ff1c82924..1c601eded81 100644 --- a/source/gameengine/GameLogic/SCA_JoystickSensor.cpp +++ b/source/gameengine/GameLogic/SCA_JoystickSensor.cpp @@ -601,7 +601,7 @@ PyObject* SCA_JoystickSensor::pyattr_get_axis_single(void *self_v, const KX_PYAT SCA_Joystick *joy = self->m_pJoystickMgr->GetJoystickDevice(self->m_joyindex); if(self->m_joymode != KX_JOYSENSORMODE_AXIS_SINGLE) { - PyErr_SetString(PyExc_TypeError, "joystick sensor is not an 'Single Axis' type"); + PyErr_SetString(PyExc_TypeError, "val = sensor.axisSingle: Joystick Sensor, not 'Single Axis' type"); return NULL; } diff --git a/source/gameengine/GameLogic/SCA_KeyboardSensor.cpp b/source/gameengine/GameLogic/SCA_KeyboardSensor.cpp index d56e5fe29dc..c946156283f 100644 --- a/source/gameengine/GameLogic/SCA_KeyboardSensor.cpp +++ b/source/gameengine/GameLogic/SCA_KeyboardSensor.cpp @@ -590,7 +590,7 @@ KX_PYMETHODDEF_DOC_O(SCA_KeyboardSensor, getKeyStatus, "\tGet the given key's status (KX_NO_INPUTSTATUS, KX_JUSTACTIVATED, KX_ACTIVE or KX_JUSTRELEASED).\n") { if (!PyInt_Check(value)) { - PyErr_SetString(PyExc_ValueError, "getKeyStatus expected an int"); + PyErr_SetString(PyExc_ValueError, "sensor.getKeyStatus(int): Keyboard Sensor, expected an int"); return NULL; } @@ -598,7 +598,7 @@ KX_PYMETHODDEF_DOC_O(SCA_KeyboardSensor, getKeyStatus, if ((keycode < SCA_IInputDevice::KX_BEGINKEY) || (keycode > SCA_IInputDevice::KX_ENDKEY)){ - PyErr_SetString(PyExc_AttributeError, "invalid keycode specified!"); + PyErr_SetString(PyExc_AttributeError, "sensor.getKeyStatus(int): Keyboard Sensor, invalid keycode specified!"); return NULL; } diff --git a/source/gameengine/GameLogic/SCA_MouseSensor.cpp b/source/gameengine/GameLogic/SCA_MouseSensor.cpp index 8f41e799b01..4dbeb156e63 100644 --- a/source/gameengine/GameLogic/SCA_MouseSensor.cpp +++ b/source/gameengine/GameLogic/SCA_MouseSensor.cpp @@ -279,7 +279,7 @@ KX_PYMETHODDEF_DOC_O(SCA_MouseSensor, getButtonStatus, if ((button < SCA_IInputDevice::KX_LEFTMOUSE) || (button > SCA_IInputDevice::KX_RIGHTMOUSE)){ - PyErr_SetString(PyExc_ValueError, "invalid button specified!"); + PyErr_SetString(PyExc_ValueError, "sensor.getButtonStatus(int): Mouse Sensor, invalid button specified!"); return NULL; } diff --git a/source/gameengine/GameLogic/SCA_PythonController.cpp b/source/gameengine/GameLogic/SCA_PythonController.cpp index 121f868a281..b8052555528 100644 --- a/source/gameengine/GameLogic/SCA_PythonController.cpp +++ b/source/gameengine/GameLogic/SCA_PythonController.cpp @@ -187,7 +187,7 @@ SCA_IActuator* SCA_PythonController::LinkedActuatorFromPy(PyObject *value) /* set the exception */ PyObject *value_str = PyObject_Repr(value); /* new ref */ - PyErr_Format(PyExc_ValueError, "'%s' not in this controllers actuator list", PyString_AsString(value_str)); + PyErr_Format(PyExc_ValueError, "'%s' not in this python controllers actuator list", PyString_AsString(value_str)); Py_DECREF(value_str); return false; @@ -417,14 +417,14 @@ PyObject* SCA_PythonController::PyGetActuators() } const char SCA_PythonController::GetSensor_doc[] = -"GetSensor (char sensorname) return linked sensor that is named [sensorname]\n"; +"getSensor (char sensorname) return linked sensor that is named [sensorname]\n"; PyObject* SCA_PythonController::PyGetSensor(PyObject* value) { char *scriptArg = PyString_AsString(value); if (scriptArg==NULL) { - PyErr_SetString(PyExc_TypeError, "expected a string (sensor name)"); + PyErr_SetString(PyExc_TypeError, "controller.getSensor(string): Python Controller, expected a string (sensor name)"); return NULL; } @@ -438,21 +438,21 @@ SCA_PythonController::PyGetSensor(PyObject* value) } } - PyErr_Format(PyExc_AttributeError, "Unable to find requested sensor \"%s\"", scriptArg); + PyErr_Format(PyExc_AttributeError, "controller.getSensor(string): Python Controller, unable to find requested sensor \"%s\"", scriptArg); return NULL; } const char SCA_PythonController::GetActuator_doc[] = -"GetActuator (char sensorname) return linked actuator that is named [actuatorname]\n"; +"getActuator (char sensorname) return linked actuator that is named [actuatorname]\n"; PyObject* SCA_PythonController::PyGetActuator(PyObject* value) { char *scriptArg = PyString_AsString(value); if (scriptArg==NULL) { - PyErr_SetString(PyExc_TypeError, "expected a string (actuator name)"); + PyErr_SetString(PyExc_TypeError, "controller.getActuator(string): Python Controller, expected a string (actuator name)"); return NULL; } @@ -465,7 +465,7 @@ SCA_PythonController::PyGetActuator(PyObject* value) } } - PyErr_Format(PyExc_AttributeError, "Unable to find requested actuator \"%s\"", scriptArg); + PyErr_Format(PyExc_AttributeError, "controller.getActuator(string): Python Controller, unable to find requested actuator \"%s\"", scriptArg); return NULL; } @@ -536,7 +536,7 @@ int SCA_PythonController::pyattr_set_script(void *self_v, const KX_PYATTRIBUTE_D char *scriptArg = PyString_AsString(value); if (scriptArg==NULL) { - PyErr_SetString(PyExc_TypeError, "expected a string (script name)"); + PyErr_SetString(PyExc_TypeError, "controller.script = string: Python Controller, expected a string script text"); return -1; } diff --git a/source/gameengine/GameLogic/SCA_RandomActuator.cpp b/source/gameengine/GameLogic/SCA_RandomActuator.cpp index 6fb10faaf8c..3a72d9b7652 100644 --- a/source/gameengine/GameLogic/SCA_RandomActuator.cpp +++ b/source/gameengine/GameLogic/SCA_RandomActuator.cpp @@ -386,7 +386,7 @@ int SCA_RandomActuator::pyattr_set_seed(void *self, const struct KX_PYATTRIBUTE_ act->m_base->SetSeed(ival); return 0; } else { - PyErr_SetString(PyExc_TypeError, "expected an integer"); + PyErr_SetString(PyExc_TypeError, "actuator.seed = int: Random Actuator, expected an integer"); return 1; } } diff --git a/source/gameengine/GameLogic/SCA_RandomSensor.cpp b/source/gameengine/GameLogic/SCA_RandomSensor.cpp index e04d2a8ab90..5ead82db428 100644 --- a/source/gameengine/GameLogic/SCA_RandomSensor.cpp +++ b/source/gameengine/GameLogic/SCA_RandomSensor.cpp @@ -224,7 +224,7 @@ int SCA_RandomSensor::pyattr_set_seed(void *self_v, const KX_PYATTRIBUTE_DEF *at { SCA_RandomSensor* self= static_cast<SCA_RandomSensor*>(self_v); if (!PyInt_Check(value)) { - PyErr_SetString(PyExc_TypeError, "expected an integer"); + PyErr_SetString(PyExc_TypeError, "sensor.seed = int: Random Sensor, expected an integer"); return -1; } self->m_basegenerator->SetSeed(PyInt_AsLong(value)); diff --git a/source/gameengine/Ketsji/BL_Shader.cpp b/source/gameengine/Ketsji/BL_Shader.cpp index 01b6805ae7a..88d920043e0 100644 --- a/source/gameengine/Ketsji/BL_Shader.cpp +++ b/source/gameengine/Ketsji/BL_Shader.cpp @@ -858,7 +858,7 @@ KX_PYMETHODDEF_DOC( BL_Shader, validate, "validate()") Py_RETURN_NONE; } if(mShader==0) { - PyErr_Format(PyExc_TypeError, "invalid shader object"); + PyErr_SetString(PyExc_TypeError, "shader.validate(): BL_Shader, invalid shader object"); return NULL; } int stat = 0; @@ -1175,7 +1175,7 @@ KX_PYMETHODDEF_DOC( BL_Shader, setUniformfv , "setUniformfv( float (list2 or lis }break; default: { - PyErr_Format(PyExc_TypeError, "Invalid list size"); + PyErr_SetString(PyExc_TypeError, "shader.setUniform4i(name, ix,iy,iz, iw): BL_Shader. invalid list size"); return NULL; }break; } @@ -1185,7 +1185,7 @@ KX_PYMETHODDEF_DOC( BL_Shader, setUniformfv , "setUniformfv( float (list2 or lis return NULL; } -KX_PYMETHODDEF_DOC( BL_Shader, setUniformiv, "setUniformiv( int (list2 or list3 or list4) )") +KX_PYMETHODDEF_DOC( BL_Shader, setUniformiv, "setUniformiv( uniform_name, (list2 or list3 or list4) )") { if(mError) { Py_RETURN_NONE; @@ -1194,70 +1194,84 @@ KX_PYMETHODDEF_DOC( BL_Shader, setUniformiv, "setUniformiv( int (list2 or list3 PyObject *listPtr =0; int array_data[4] = {0,0,0,0}; - if(PyArg_ParseTuple(args, "sO:setUniformiv", &uniform, &listPtr)) + if(!PyArg_ParseTuple(args, "sO:setUniformiv", &uniform, &listPtr)) + return NULL; + + int loc = GetUniformLocation(uniform); + + if(loc == -1) { + PyErr_SetString(PyExc_TypeError, "shader.setUniformiv(...): BL_Shader, first string argument is not a valid uniform value"); + return NULL; + } + + if(!PySequence_Check(listPtr)) { + PyErr_SetString(PyExc_TypeError, "shader.setUniformiv(...): BL_Shader, second argument is not a sequence"); + return NULL; + } + + unsigned int list_size = PySequence_Size(listPtr); + + for(unsigned int i=0; (i<list_size && i<4); i++) { - int loc = GetUniformLocation(uniform); - if(loc != -1) + PyObject *item = PySequence_GetItem(listPtr, i); + array_data[i] = PyInt_AsLong(item); + Py_DECREF(item); + } + + if(PyErr_Occurred()) { + PyErr_SetString(PyExc_TypeError, "shader.setUniformiv(...): BL_Shader, one or more values in the list is not an int"); + return NULL; + } + + /* Sanity checks done! */ + + switch(list_size) + { + case 2: { - if(PySequence_Check(listPtr)) - { - unsigned int list_size = PySequence_Size(listPtr); - - for(unsigned int i=0; (i<list_size && i<4); i++) - { - PyObject *item = PySequence_GetItem(listPtr, i); - array_data[i] = PyInt_AsLong(item); - Py_DECREF(item); - } - switch(list_size) - { - case 2: - { - int array2[2] = { array_data[0],array_data[1]}; + int array2[2] = { array_data[0],array_data[1]}; #ifdef SORT_UNIFORMS - SetUniformiv(loc, BL_Uniform::UNI_INT2, array2, sizeof(int)*2); + SetUniformiv(loc, BL_Uniform::UNI_INT2, array2, sizeof(int)*2); #else - SetUniform(loc, array2, 2); + SetUniform(loc, array2, 2); #endif - Py_RETURN_NONE; - } break; - case 3: - { - int array3[3] = { array_data[0],array_data[1],array_data[2] }; + Py_RETURN_NONE; + } break; + case 3: + { + int array3[3] = { array_data[0],array_data[1],array_data[2] }; #ifdef SORT_UNIFORMS - SetUniformiv(loc, BL_Uniform::UNI_INT3, array3, sizeof(int)*3); - + SetUniformiv(loc, BL_Uniform::UNI_INT3, array3, sizeof(int)*3); + #else - SetUniform(loc, array3, 3); + SetUniform(loc, array3, 3); #endif - Py_RETURN_NONE; - }break; - case 4: - { - int array4[4] = { array_data[0],array_data[1],array_data[2],array_data[3] }; + Py_RETURN_NONE; + }break; + case 4: + { + int array4[4] = { array_data[0],array_data[1],array_data[2],array_data[3] }; #ifdef SORT_UNIFORMS - SetUniformiv(loc, BL_Uniform::UNI_INT4, array4, sizeof(int)*4); - + SetUniformiv(loc, BL_Uniform::UNI_INT4, array4, sizeof(int)*4); + #else - SetUniform(loc, array4, 4); + SetUniform(loc, array4, 4); #endif - Py_RETURN_NONE; - }break; - default: - { - PyErr_Format(PyExc_TypeError, "Invalid list size"); - return NULL; - }break; - } - } - } + Py_RETURN_NONE; + }break; + default: + { + PyErr_SetString(PyExc_TypeError, "shader.setUniformiv(...): BL_Shader, second argument, invalid list size, expected an int list between 2 and 4"); + return NULL; + }break; } - return NULL; + + Py_RETURN_NONE; } KX_PYMETHODDEF_DOC( BL_Shader, setUniformMatrix4, -"setUniformMatrix4(uniform-name, mat-4x4, transpose(row-major=true, col-major=false)" ) +"setUniformMatrix4(uniform_name, mat-4x4, transpose(row-major=true, col-major=false)" ) { if(mError) { Py_RETURN_NONE; @@ -1273,30 +1287,38 @@ KX_PYMETHODDEF_DOC( BL_Shader, setUniformMatrix4, const char *uniform=""; PyObject *matrix=0; int transp=1; // MT_ is row major so transpose by default.... - if(PyArg_ParseTuple(args, "sO|i:setUniformMatrix4",&uniform, &matrix,&transp)) - { - int loc = GetUniformLocation(uniform); - if(loc != -1) - { - MT_Matrix4x4 mat; - if (PyMatTo(matrix, mat)) - { + + if(!PyArg_ParseTuple(args, "sO|i:setUniformMatrix4",&uniform, &matrix,&transp)) + return NULL; + + int loc = GetUniformLocation(uniform); + + if(loc == -1) { + PyErr_SetString(PyExc_TypeError, "shader.setUniformMatrix4(...): BL_Shader, first string argument is not a valid uniform value"); + return NULL; + } + + MT_Matrix4x4 mat; + + if (!PyMatTo(matrix, mat)) { + PyErr_SetString(PyExc_TypeError, "shader.setUniformMatrix4(...): BL_Shader, second argument cannot be converted into a 4x4 matrix"); + return NULL; + } + + /* Sanity checks done! */ + #ifdef SORT_UNIFORMS - mat.getValue(matr); - SetUniformfv(loc, BL_Uniform::UNI_MAT4, matr, (sizeof(float)*16), (transp!=0) ); + mat.getValue(matr); + SetUniformfv(loc, BL_Uniform::UNI_MAT4, matr, (sizeof(float)*16), (transp!=0) ); #else - SetUniform(loc,mat,(transp!=0)); + SetUniform(loc,mat,(transp!=0)); #endif - Py_RETURN_NONE; - } - } - } - return NULL; + Py_RETURN_NONE; } KX_PYMETHODDEF_DOC( BL_Shader, setUniformMatrix3, -"setUniformMatrix3(uniform-name, list[3x3], transpose(row-major=true, col-major=false)" ) +"setUniformMatrix3(uniform_name, list[3x3], transpose(row-major=true, col-major=false)" ) { if(mError) { Py_RETURN_NONE; @@ -1311,25 +1333,32 @@ KX_PYMETHODDEF_DOC( BL_Shader, setUniformMatrix3, const char *uniform=""; PyObject *matrix=0; int transp=1; // MT_ is row major so transpose by default.... - if(PyArg_ParseTuple(args, "sO|i:setUniformMatrix3",&uniform, &matrix,&transp)) - { - int loc = GetUniformLocation(uniform); - if(loc != -1) - { - MT_Matrix3x3 mat; - if (PyMatTo(matrix, mat)) - { + if(!PyArg_ParseTuple(args, "sO|i:setUniformMatrix3",&uniform, &matrix,&transp)) + return NULL; + + int loc = GetUniformLocation(uniform); + + if(loc == -1) { + PyErr_SetString(PyExc_TypeError, "shader.setUniformMatrix3(...): BL_Shader, first string argument is not a valid uniform value"); + return NULL; + } + + + MT_Matrix3x3 mat; + + if (!PyMatTo(matrix, mat)) { + PyErr_SetString(PyExc_TypeError, "shader.setUniformMatrix3(...): BL_Shader, second argument cannot be converted into a 3x3 matrix"); + return NULL; + } + + #ifdef SORT_UNIFORMS - mat.getValue(matr); - SetUniformfv(loc, BL_Uniform::UNI_MAT3, matr, (sizeof(float)*9), (transp!=0) ); + mat.getValue(matr); + SetUniformfv(loc, BL_Uniform::UNI_MAT3, matr, (sizeof(float)*9), (transp!=0) ); #else - SetUniform(loc,mat,(transp!=0)); + SetUniform(loc,mat,(transp!=0)); #endif - Py_RETURN_NONE; - } - } - } - return NULL; + Py_RETURN_NONE; } KX_PYMETHODDEF_DOC( BL_Shader, setAttrib, "setAttrib(enum)" ) @@ -1337,18 +1366,20 @@ KX_PYMETHODDEF_DOC( BL_Shader, setAttrib, "setAttrib(enum)" ) if(mError) { Py_RETURN_NONE; } + int attr=0; - if(PyArg_ParseTuple(args, "i:setAttrib", &attr )) { - if(mShader==0) { - PyErr_Format(PyExc_ValueError, "invalid shader object"); - return NULL; - } - mAttr=SHD_TANGENT; - glUseProgramObjectARB(mShader); - glBindAttribLocationARB(mShader, mAttr, "Tangent"); - Py_RETURN_NONE; + + if(!PyArg_ParseTuple(args, "i:setAttrib", &attr )) + return NULL; + + if(mShader==0) { + PyErr_SetString(PyExc_ValueError, "shader.setAttrib() BL_Shader, invalid shader object"); + return NULL; } - return NULL; + mAttr=SHD_TANGENT; /* What the heck is going on here - attr is just ignored??? - Campbell */ + glUseProgramObjectARB(mShader); + glBindAttribLocationARB(mShader, mAttr, "Tangent"); + Py_RETURN_NONE; } diff --git a/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.cpp b/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.cpp index 0c23c9b2712..7782567943e 100644 --- a/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.cpp +++ b/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.cpp @@ -262,7 +262,7 @@ PyObject* KX_NetworkMessageSensor::PySetSubjectFilterText(PyObject* value) ShowDeprecationWarning("setSubjectFilterText()", "subject"); char* Subject = PyString_AsString(value); if (Subject==NULL) { - PyErr_SetString(PyExc_TypeError, "expected a string message"); + PyErr_SetString(PyExc_TypeError, "sensor.tsetSubjectFilterText(string): KX_NetworkMessageSensor, expected a string message"); return NULL; } diff --git a/source/gameengine/Ketsji/KX_BlenderMaterial.cpp b/source/gameengine/Ketsji/KX_BlenderMaterial.cpp index 6722cd232fe..849332008ce 100644 --- a/source/gameengine/Ketsji/KX_BlenderMaterial.cpp +++ b/source/gameengine/Ketsji/KX_BlenderMaterial.cpp @@ -841,7 +841,7 @@ KX_PYMETHODDEF_DOC( KX_BlenderMaterial, getShader , "getShader()") } Py_RETURN_NONE; } - PyErr_Format(PyExc_ValueError, "GLSL Error"); + PyErr_SetString(PyExc_ValueError, "material.getShader(): KX_BlenderMaterial, GLSL Error"); return NULL; } @@ -907,7 +907,7 @@ KX_PYMETHODDEF_DOC( KX_BlenderMaterial, setBlending , "setBlending( GameLogic.sr if(value_found[0] && value_found[1]) break; } if(!value_found[0] || !value_found[1]) { - PyErr_Format(PyExc_ValueError, "invalid enum."); + PyErr_SetString(PyExc_ValueError, "material.setBlending(int, int): KX_BlenderMaterial, invalid enum."); return NULL; } mUserDefBlend = true; diff --git a/source/gameengine/Ketsji/KX_Camera.cpp b/source/gameengine/Ketsji/KX_Camera.cpp index db8186e4586..c8575424751 100644 --- a/source/gameengine/Ketsji/KX_Camera.cpp +++ b/source/gameengine/Ketsji/KX_Camera.cpp @@ -578,7 +578,7 @@ KX_PYMETHODDEF_DOC_VARARGS(KX_Camera, sphereInsideFrustum, } } - PyErr_SetString(PyExc_TypeError, "sphereInsideFrustum: Expected arguments: (center, radius)"); + PyErr_SetString(PyExc_TypeError, "camera.sphereInsideFrustum(center, radius): KX_Camera, expected arguments: (center, radius)"); return NULL; } @@ -611,7 +611,7 @@ KX_PYMETHODDEF_DOC_O(KX_Camera, boxInsideFrustum, unsigned int num_points = PySequence_Size(value); if (num_points != 8) { - PyErr_Format(PyExc_TypeError, "boxInsideFrustum: Expected eight (8) points, got %d", num_points); + PyErr_Format(PyExc_TypeError, "camera.boxInsideFrustum(box): KX_Camera, expected eight (8) points, got %d", num_points); return NULL; } @@ -650,7 +650,7 @@ KX_PYMETHODDEF_DOC_O(KX_Camera, pointInsideFrustum, return PyInt_FromLong(PointInsideFrustum(point)); /* new ref */ } - PyErr_SetString(PyExc_TypeError, "pointInsideFrustum: Expected point argument."); + PyErr_SetString(PyExc_TypeError, "camera.pointInsideFrustum(point): KX_Camera, expected point argument."); return NULL; } @@ -726,7 +726,7 @@ KX_PYMETHODDEF_DOC_O(KX_Camera, setProjectionMatrix, MT_Matrix4x4 mat; if (!PyMatTo(value, mat)) { - PyErr_SetString(PyExc_TypeError, "setProjectionMatrix: Expected 4x4 list as matrix argument."); + PyErr_SetString(PyExc_TypeError, "camera.setProjectionMatrix(matrix): KX_Camera, expected 4x4 list as matrix argument."); return NULL; } @@ -742,7 +742,7 @@ KX_PYMETHODDEF_DOC_O(KX_Camera, enableViewport, int viewport = PyObject_IsTrue(value); if (viewport == -1) { - PyErr_SetString(PyExc_ValueError, "expected True/False or 0/1"); + PyErr_SetString(PyExc_ValueError, "camera.enableViewport(bool): KX_Camera, expected True/False or 0/1"); return NULL; } @@ -789,7 +789,7 @@ int KX_Camera::pyattr_set_perspective(void *self_v, const KX_PYATTRIBUTE_DEF *at KX_Camera* self= static_cast<KX_Camera*>(self_v); int param = PyObject_IsTrue( value ); if (param == -1) { - PyErr_SetString(PyExc_AttributeError, "expected True or False"); + PyErr_SetString(PyExc_AttributeError, "camera.perspective = bool: KX_Camera, expected True/False or 0/1"); return -1; } @@ -808,7 +808,7 @@ int KX_Camera::pyattr_set_lens(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, KX_Camera* self= static_cast<KX_Camera*>(self_v); float param = PyFloat_AsDouble(value); if (param == -1) { - PyErr_SetString(PyExc_AttributeError, "expected a float greater then zero"); + PyErr_SetString(PyExc_AttributeError, "camera.lens = float: KX_Camera, expected a float greater then zero"); return -1; } @@ -828,7 +828,7 @@ int KX_Camera::pyattr_set_near(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, KX_Camera* self= static_cast<KX_Camera*>(self_v); float param = PyFloat_AsDouble(value); if (param == -1) { - PyErr_SetString(PyExc_AttributeError, "expected a float greater then zero"); + PyErr_SetString(PyExc_AttributeError, "camera.near = float: KX_Camera, expected a float greater then zero"); return -1; } @@ -848,7 +848,7 @@ int KX_Camera::pyattr_set_far(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, P KX_Camera* self= static_cast<KX_Camera*>(self_v); float param = PyFloat_AsDouble(value); if (param == -1) { - PyErr_SetString(PyExc_AttributeError, "expected a float greater then zero"); + PyErr_SetString(PyExc_AttributeError, "camera.far = float: KX_Camera, expected a float greater then zero"); return -1; } diff --git a/source/gameengine/Ketsji/KX_ConstraintActuator.cpp b/source/gameengine/Ketsji/KX_ConstraintActuator.cpp index 462abd3a584..1ce7fac0cfe 100644 --- a/source/gameengine/Ketsji/KX_ConstraintActuator.cpp +++ b/source/gameengine/Ketsji/KX_ConstraintActuator.cpp @@ -652,7 +652,7 @@ int KX_ConstraintActuator::pyattr_check_direction(void *self, const struct KX_PY MT_Vector3 dir(act->m_refDirection); MT_Scalar len = dir.length(); if (MT_fuzzyZero(len)) { - PyErr_SetString(PyExc_ValueError, "Invalid direction"); + PyErr_SetString(PyExc_ValueError, "actuator.direction = vec: KX_ConstraintActuator, invalid direction"); return 1; } act->m_refDirVector = dir/len; diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp b/source/gameengine/Ketsji/KX_GameObject.cpp index 9fe7ab75267..af1dc7f67b2 100644 --- a/source/gameengine/Ketsji/KX_GameObject.cpp +++ b/source/gameengine/Ketsji/KX_GameObject.cpp @@ -1187,13 +1187,13 @@ PyObject* KX_GameObject::PyReplaceMesh(PyObject* value) meshname = PyString_AsString(value); if (meshname==NULL) { - PyErr_SetString(PyExc_ValueError, "Expected a mesh name"); + PyErr_SetString(PyExc_ValueError, "gameOb.replaceMesh(value): KX_GameObject, expected a mesh name"); return NULL; } mesh_pt = SCA_ILogicBrick::m_sCurrentLogicManager->GetMeshByName(STR_String(meshname)); if (mesh_pt==NULL) { - PyErr_SetString(PyExc_ValueError, "The mesh name given does not exist"); + PyErr_SetString(PyExc_ValueError, "gameOb.replaceMesh(value): KX_GameObject, the mesh name given does not exist"); return NULL; } scene->ReplaceMesh(this, (class RAS_MeshObject*)mesh_pt); @@ -1259,8 +1259,8 @@ PyObject *KX_GameObject::Map_GetItem(PyObject *self_v, PyObject *item) return pyconvert; } else { - if(attr_str) PyErr_Format(PyExc_KeyError, "KX_GameObject key \"%s\" does not exist", attr_str); - else PyErr_SetString(PyExc_KeyError, "KX_GameObject key does not exist"); + if(attr_str) PyErr_Format(PyExc_KeyError, "value = gameOb[key]: KX_GameObject, key \"%s\" does not exist", attr_str); + else PyErr_SetString(PyExc_KeyError, "value = gameOb[key]: KX_GameObject, key does not exist"); return NULL; } @@ -1290,8 +1290,8 @@ int KX_GameObject::Map_SetItem(PyObject *self_v, PyObject *key, PyObject *val) del |= (PyDict_DelItem(self->m_attr_dict, key)==0) ? 1:0; if (del==0) { - if(attr_str) PyErr_Format(PyExc_KeyError, "KX_GameObject key \"%s\" not found", attr_str); - else PyErr_SetString(PyExc_KeyError, "KX_GameObject key not found"); + if(attr_str) PyErr_Format(PyExc_KeyError, "gameOb[key] = value: KX_GameObject, key \"%s\" could not be set", attr_str); + else PyErr_SetString(PyExc_KeyError, "gameOb[key] = value: KX_GameObject, key could not be set"); return -1; } else if (self->m_attr_dict) { @@ -1342,8 +1342,8 @@ int KX_GameObject::Map_SetItem(PyObject *self_v, PyObject *key, PyObject *val) set= 1; } else { - if(attr_str) PyErr_Format(PyExc_KeyError, "KX_GameObject key \"%s\" not be added to internal dictionary", attr_str); - else PyErr_SetString(PyExc_KeyError, "KX_GameObject key not be added to internal dictionary"); + if(attr_str) PyErr_Format(PyExc_KeyError, "gameOb[key] = value: KX_GameObject, key \"%s\" not be added to internal dictionary", attr_str); + else PyErr_SetString(PyExc_KeyError, "gameOb[key] = value: KX_GameObject, key not be added to internal dictionary"); } } @@ -1424,7 +1424,7 @@ int KX_GameObject::pyattr_set_mass(void *self_v, const KX_PYATTRIBUTE_DEF *attrd KX_IPhysicsController *spc = self->GetPhysicsController(); MT_Scalar val = PyFloat_AsDouble(value); if (val < 0.0f) { /* also accounts for non float */ - PyErr_SetString(PyExc_AttributeError, "expected a float zero or above"); + PyErr_SetString(PyExc_AttributeError, "gameOb.mass = float: KX_GameObject, expected a float zero or above"); return 1; } @@ -1447,7 +1447,7 @@ int KX_GameObject::pyattr_set_lin_vel_min(void *self_v, const KX_PYATTRIBUTE_DEF KX_IPhysicsController *spc = self->GetPhysicsController(); MT_Scalar val = PyFloat_AsDouble(value); if (val < 0.0f) { /* also accounts for non float */ - PyErr_SetString(PyExc_AttributeError, "expected a float zero or above"); + PyErr_SetString(PyExc_AttributeError, "gameOb.linVelocityMin = float: KX_GameObject, expected a float zero or above"); return 1; } @@ -1470,7 +1470,7 @@ int KX_GameObject::pyattr_set_lin_vel_max(void *self_v, const KX_PYATTRIBUTE_DEF KX_IPhysicsController *spc = self->GetPhysicsController(); MT_Scalar val = PyFloat_AsDouble(value); if (val < 0.0f) { /* also accounts for non float */ - PyErr_SetString(PyExc_AttributeError, "expected a float zero or above"); + PyErr_SetString(PyExc_AttributeError, "gameOb.linVelocityMax = float: KX_GameObject, expected a float zero or above"); return 1; } @@ -1492,7 +1492,7 @@ int KX_GameObject::pyattr_set_visible(void *self_v, const KX_PYATTRIBUTE_DEF *at KX_GameObject* self= static_cast<KX_GameObject*>(self_v); int param = PyObject_IsTrue( value ); if (param == -1) { - PyErr_SetString(PyExc_AttributeError, "expected True or False"); + PyErr_SetString(PyExc_AttributeError, "gameOb.visible = bool: KX_GameObject, expected True or False"); return 1; } @@ -1569,7 +1569,7 @@ int KX_GameObject::pyattr_set_localOrientation(void *self_v, const KX_PYATTRIBUT { KX_GameObject* self= static_cast<KX_GameObject*>(self_v); if (!PySequence_Check(value)) { - PyErr_SetString(PyExc_AttributeError, "'orientation' attribute needs to be a sequence"); + PyErr_SetString(PyExc_AttributeError, "gameOb.orientation = [...]: KX_GameObject, expected a sequence"); return 1; } @@ -1609,7 +1609,7 @@ int KX_GameObject::pyattr_set_localOrientation(void *self_v, const KX_PYATTRIBUT return 1; } - PyErr_SetString(PyExc_AttributeError, "could not set the orientation from a 3x3 matrix, quaternion or euler sequence"); + PyErr_SetString(PyExc_AttributeError, "gameOb.orientation = [...]: KX_GameObject, could not set the orientation from a 3x3 matrix, quaternion or euler sequence"); return 1; } @@ -1658,7 +1658,7 @@ int KX_GameObject::pyattr_set_timeOffset(void *self_v, const KX_PYATTRIBUTE_DEF MT_Scalar val = PyFloat_AsDouble(value); SG_Node* sg_parent= self->GetSGNode()->GetSGParent(); if (val < 0.0f) { /* also accounts for non float */ - PyErr_SetString(PyExc_AttributeError, "expected a float zero or above"); + PyErr_SetString(PyExc_AttributeError, "gameOb.timeOffset = float: KX_GameObject, expected a float zero or above"); return 1; } if (sg_parent && sg_parent->IsSlowParent()) @@ -1682,13 +1682,13 @@ int KX_GameObject::pyattr_set_state(void *self_v, const KX_PYATTRIBUTE_DEF *attr unsigned int state = 0; if (state_i == -1 && PyErr_Occurred()) { - PyErr_SetString(PyExc_TypeError, "expected an int bit field"); + PyErr_SetString(PyExc_TypeError, "gameOb.state = int: KX_GameObject, expected an int bit field"); return 1; } state |= state_i; if ((state & ((1<<30)-1)) == 0) { - PyErr_SetString(PyExc_AttributeError, "The state bitfield was not between 0 and 30 (1<<0 and 1<<29)"); + PyErr_SetString(PyExc_AttributeError, "gameOb.state = int: KX_GameObject, state bitfield was not between 0 and 30 (1<<0 and 1<<29)"); return 1; } self->SetState(state); @@ -1701,7 +1701,7 @@ PyObject* KX_GameObject::pyattr_get_meshes(void *self_v, const KX_PYATTRIBUTE_DE PyObject *meshes= PyList_New(self->m_meshes.size()); int i; - for(i=0; i < (int)self->m_meshes.size(); i++) + for(i=0; i < self->m_meshes.size(); i++) { KX_MeshProxy* meshproxy = new KX_MeshProxy(self->m_meshes[i]); PyList_SET_ITEM(meshes, i, meshproxy->GetProxy()); @@ -1847,7 +1847,7 @@ int KX_GameObject::py_setattro(PyObject *attr, PyObject *value) // py_setattro m ret= PY_SET_ATTR_SUCCESS; } else { - PyErr_Format(PyExc_AttributeError, "failed assigning value to KX_GameObject internal dictionary"); + PyErr_Format(PyExc_AttributeError, "gameOb.myAttr = value: KX_GameObject, failed assigning value to internal dictionary"); ret= PY_SET_ATTR_FAIL; } } @@ -1866,7 +1866,7 @@ int KX_GameObject::py_delattro(PyObject *attr) if (m_attr_dict && (PyDict_DelItem(m_attr_dict, attr) == 0)) return 0; - PyErr_Format(PyExc_AttributeError, "attribute \"%s\" dosnt exist", attr_str); + PyErr_Format(PyExc_AttributeError, "del gameOb.myAttr: KX_GameObject, attribute \"%s\" dosnt exist", attr_str); return 1; } @@ -2390,7 +2390,7 @@ KX_PYMETHODDEF_DOC_O(KX_GameObject, getVectTo, toPoint = other->NodeGetWorldPosition(); } else { - PyErr_SetString(PyExc_TypeError, "Expected a 3D Vector or GameObject type"); + PyErr_SetString(PyExc_TypeError, "gameOb.getVectTo(other): KX_GameObject, expected a 3D Vector or KX_GameObject type"); return NULL; } } @@ -2484,7 +2484,7 @@ KX_PYMETHODDEF_DOC(KX_GameObject, rayCastTo, toPoint = other->NodeGetWorldPosition(); } else { - PyErr_SetString(PyExc_TypeError, "the first argument to rayCastTo must be a vector or a KX_GameObject"); + PyErr_SetString(PyExc_TypeError, "gameOb.rayCastTo(other,dist,prop): KX_GameObject, the first argument to rayCastTo must be a vector or a KX_GameObject"); return NULL; } } @@ -2577,7 +2577,7 @@ KX_PYMETHODDEF_DOC(KX_GameObject, rayCast, fromPoint = other->NodeGetWorldPosition(); } else { - PyErr_SetString(PyExc_TypeError, "the second optional argument to rayCast must be a vector or a KX_GameObject"); + PyErr_SetString(PyExc_TypeError, "gameOb.rayCast(to,from,dist,prop,face,xray,poly): KX_GameObject, the second optional argument to rayCast must be a vector or a KX_GameObject"); return NULL; } } diff --git a/source/gameengine/Ketsji/KX_MeshProxy.cpp b/source/gameengine/Ketsji/KX_MeshProxy.cpp index ded862fb21d..e2c59ab4242 100644 --- a/source/gameengine/Ketsji/KX_MeshProxy.cpp +++ b/source/gameengine/Ketsji/KX_MeshProxy.cpp @@ -243,7 +243,7 @@ PyObject* KX_MeshProxy::PyGetPolygon(PyObject* args, PyObject* kwds) if (polyindex<0 || polyindex >= m_meshobj->NumPolygons()) { - PyErr_SetString(PyExc_AttributeError, "Invalid polygon index"); + PyErr_SetString(PyExc_AttributeError, "mesh.getPolygon(int): KX_MeshProxy, invalid polygon index"); return NULL; } @@ -254,7 +254,7 @@ PyObject* KX_MeshProxy::PyGetPolygon(PyObject* args, PyObject* kwds) polyob = (new KX_PolyProxy(m_meshobj, polygon))->NewProxy(true); } else { - PyErr_SetString(PyExc_AttributeError, "polygon is NULL, unknown reason"); + PyErr_SetString(PyExc_AttributeError, "mesh.getPolygon(int): KX_MeshProxy, polygon is NULL, unknown reason"); } return polyob; } diff --git a/source/gameengine/Ketsji/KX_PolyProxy.cpp b/source/gameengine/Ketsji/KX_PolyProxy.cpp index 5888579431a..2e5dd72db0e 100644 --- a/source/gameengine/Ketsji/KX_PolyProxy.cpp +++ b/source/gameengine/Ketsji/KX_PolyProxy.cpp @@ -242,7 +242,7 @@ KX_PYMETHODDEF_DOC(KX_PolyProxy, getVertexIndex, } if (index < 0 || index > 3) { - PyErr_SetString(PyExc_AttributeError, "Valid range for index is 0-3"); + PyErr_SetString(PyExc_AttributeError, "poly.getVertexIndex(int): KX_PolyProxy, expected an index between 0-3"); return NULL; } if (index < m_polygon->VertexCount()) diff --git a/source/gameengine/Ketsji/KX_PyMath.h b/source/gameengine/Ketsji/KX_PyMath.h index 39c9c358792..4a64063aaa1 100644 --- a/source/gameengine/Ketsji/KX_PyMath.h +++ b/source/gameengine/Ketsji/KX_PyMath.h @@ -92,18 +92,35 @@ bool PyMatTo(PyObject* pymat, T& mat) } /** - * Converts a python list to a MT class. + * Converts a python sequence to a MT class. */ template<class T> bool PyVecTo(PyObject* pyval, T& vec) { - if (PySequence_Check(pyval)) + + if(PyTuple_Check(pyval)) + { + unsigned int numitems = PyTuple_GET_SIZE(pyval); + if (numitems != Size(vec)) { + PyErr_Format(PyExc_AttributeError, "error setting vector, %d args, should be %d", numitems, Size(vec)); + return false; + } + + for (unsigned int x = 0; x < numitems; x++) + vec[x] = PyFloat_AsDouble(PyTuple_GET_ITEM(pyval, x)); /* borrow ref */ + + if (PyErr_Occurred()) { + PyErr_SetString(PyExc_AttributeError, "one or more of the items in the sequence was not a float"); + return false; + } + + return true; + } + else if (PySequence_Check(pyval)) { unsigned int numitems = PySequence_Size(pyval); if (numitems != Size(vec)) { - char err[128]; - sprintf(err, "error setting vector, %d args, should be %d", numitems, Size(vec)); - PyErr_SetString(PyExc_AttributeError, err); + PyErr_Format(PyExc_AttributeError, "error setting vector, %d args, should be %d", numitems, Size(vec)); return false; } @@ -122,9 +139,7 @@ bool PyVecTo(PyObject* pyval, T& vec) return true; } else { - char err[128]; - sprintf(err, "not a sequence type, expected a sequence of numbers size %d", Size(vec)); - PyErr_SetString(PyExc_AttributeError, err); + PyErr_Format(PyExc_AttributeError, "not a sequence type, expected a sequence of numbers size %d", Size(vec)); } return false; diff --git a/source/gameengine/Ketsji/KX_PythonInit.cpp b/source/gameengine/Ketsji/KX_PythonInit.cpp index 2227072d2e7..097d20fe0e5 100644 --- a/source/gameengine/Ketsji/KX_PythonInit.cpp +++ b/source/gameengine/Ketsji/KX_PythonInit.cpp @@ -553,7 +553,7 @@ static PyObject* gPySetEyeSeparation(PyObject*, PyObject* args) return NULL; if (!gp_Rasterizer) { - PyErr_SetString(PyExc_RuntimeError, "Rasterizer not available"); + PyErr_SetString(PyExc_RuntimeError, "Rasterizer.setEyeSeparation(float), Rasterizer not available"); return NULL; } @@ -565,7 +565,7 @@ static PyObject* gPySetEyeSeparation(PyObject*, PyObject* args) static PyObject* gPyGetEyeSeparation(PyObject*) { if (!gp_Rasterizer) { - PyErr_SetString(PyExc_RuntimeError, "Rasterizer not available"); + PyErr_SetString(PyExc_RuntimeError, "Rasterizer.getEyeSeparation(), Rasterizer not available"); return NULL; } @@ -579,7 +579,7 @@ static PyObject* gPySetFocalLength(PyObject*, PyObject* args) return NULL; if (!gp_Rasterizer) { - PyErr_SetString(PyExc_RuntimeError, "Rasterizer not available"); + PyErr_SetString(PyExc_RuntimeError, "Rasterizer.setFocalLength(float), Rasterizer not available"); return NULL; } @@ -591,7 +591,7 @@ static PyObject* gPySetFocalLength(PyObject*, PyObject* args) static PyObject* gPyGetFocalLength(PyObject*, PyObject*, PyObject*) { if (!gp_Rasterizer) { - PyErr_SetString(PyExc_RuntimeError, "Rasterizer not available"); + PyErr_SetString(PyExc_RuntimeError, "Rasterizer.getFocalLength(), Rasterizer not available"); return NULL; } @@ -624,7 +624,7 @@ static PyObject* gPySetMistColor(PyObject*, PyObject* value) return NULL; if (!gp_Rasterizer) { - PyErr_SetString(PyExc_RuntimeError, "Rasterizer not available"); + PyErr_SetString(PyExc_RuntimeError, "Rasterizer.setMistColor(color), Rasterizer not available"); return NULL; } gp_Rasterizer->SetFogColor(vec[0], vec[1], vec[2]); @@ -642,7 +642,7 @@ static PyObject* gPySetMistStart(PyObject*, PyObject* args) return NULL; if (!gp_Rasterizer) { - PyErr_SetString(PyExc_RuntimeError, "Rasterizer not available"); + PyErr_SetString(PyExc_RuntimeError, "Rasterizer.setMistStart(float), Rasterizer not available"); return NULL; } @@ -661,7 +661,7 @@ static PyObject* gPySetMistEnd(PyObject*, PyObject* args) return NULL; if (!gp_Rasterizer) { - PyErr_SetString(PyExc_RuntimeError, "Rasterizer not available"); + PyErr_SetString(PyExc_RuntimeError, "Rasterizer.setMistEnd(float), Rasterizer not available"); return NULL; } @@ -679,7 +679,7 @@ static PyObject* gPySetAmbientColor(PyObject*, PyObject* value) return NULL; if (!gp_Rasterizer) { - PyErr_SetString(PyExc_RuntimeError, "Rasterizer not available"); + PyErr_SetString(PyExc_RuntimeError, "Rasterizer.setAmbientColor(color), Rasterizer not available"); return NULL; } gp_Rasterizer->SetAmbientColor(vec[0], vec[1], vec[2]); @@ -711,7 +711,7 @@ static PyObject* gPyEnableMotionBlur(PyObject*, PyObject* args) return NULL; if (!gp_Rasterizer) { - PyErr_SetString(PyExc_RuntimeError, "Rasterizer not available"); + PyErr_SetString(PyExc_RuntimeError, "Rasterizer.enableMotionBlur(float), Rasterizer not available"); return NULL; } @@ -723,7 +723,7 @@ static PyObject* gPyEnableMotionBlur(PyObject*, PyObject* args) static PyObject* gPyDisableMotionBlur(PyObject*, PyObject* args) { if (!gp_Rasterizer) { - PyErr_SetString(PyExc_RuntimeError, "Rasterizer not available"); + PyErr_SetString(PyExc_RuntimeError, "Rasterizer.disableMotionBlur(), Rasterizer not available"); return NULL; } @@ -763,7 +763,7 @@ static PyObject* gPySetGLSLMaterialSetting(PyObject*, flag = getGLSLSettingFlag(setting); if (flag==-1) { - PyErr_SetString(PyExc_ValueError, "glsl setting is not known"); + PyErr_SetString(PyExc_ValueError, "Rasterizer.setGLSLMaterialSetting(string): glsl setting is not known"); return NULL; } @@ -804,7 +804,7 @@ static PyObject* gPyGetGLSLMaterialSetting(PyObject*, flag = getGLSLSettingFlag(setting); if (flag==-1) { - PyErr_SetString(PyExc_ValueError, "glsl setting is not known"); + PyErr_SetString(PyExc_ValueError, "Rasterizer.getGLSLMaterialSetting(string): glsl setting is not known"); return NULL; } @@ -832,7 +832,7 @@ static PyObject* gPySetMaterialType(PyObject*, else if(type == KX_TEXFACE_MATERIAL) flag = 0; else { - PyErr_SetString(PyExc_ValueError, "material type is not known"); + PyErr_SetString(PyExc_ValueError, "Rasterizer.setMaterialType(int): material type is not known"); return NULL; } @@ -863,7 +863,7 @@ static PyObject* gPyDrawLine(PyObject*, PyObject* args) PyObject* ob_color; if (!gp_Rasterizer) { - PyErr_SetString(PyExc_RuntimeError, "Rasterizer not available"); + PyErr_SetString(PyExc_RuntimeError, "Rasterizer.drawLine(obFrom, obTo, color): Rasterizer not available"); return NULL; } @@ -1270,7 +1270,7 @@ PyObject *KXpy_reload(PyObject *self, PyObject *args) { return newmodule; if (found==0) /* if its found but could not import then it has its own error */ - PyErr_SetString(PyExc_ImportError, "failed to reload from blenders internal text"); + PyErr_SetString(PyExc_ImportError, "reload(module): failed to reload from blenders internal text"); return newmodule; } @@ -1517,7 +1517,7 @@ static PyObject* gPyEventToString(PyObject*, PyObject* value) PyErr_Clear(); // incase there was an error clearing Py_DECREF(mod); - if (!ret) PyErr_SetString(PyExc_ValueError, "expected a valid int keyboard event"); + if (!ret) PyErr_SetString(PyExc_ValueError, "GameKeys.EventToString(int): expected a valid int keyboard event"); else Py_INCREF(ret); return ret; diff --git a/source/gameengine/Ketsji/KX_SCA_ReplaceMeshActuator.cpp b/source/gameengine/Ketsji/KX_SCA_ReplaceMeshActuator.cpp index 44dedb38429..53067e94cd8 100644 --- a/source/gameengine/Ketsji/KX_SCA_ReplaceMeshActuator.cpp +++ b/source/gameengine/Ketsji/KX_SCA_ReplaceMeshActuator.cpp @@ -121,7 +121,7 @@ int KX_SCA_ReplaceMeshActuator::pyattr_set_mesh(void *self, const struct KX_PYAT } else if (PyString_Check(value)) { void* mesh = SCA_ILogicBrick::m_sCurrentLogicManager->GetMeshByName(STR_String(PyString_AsString(value))); if (mesh==NULL) { - PyErr_SetString(PyExc_ValueError, "The mesh name given does not exist"); + PyErr_SetString(PyExc_ValueError, "actuator.mesh = string: Replace Mesh Actuator, mesh name given does not exist"); return 1; } actuator->m_mesh= (class RAS_MeshObject*)mesh; @@ -129,7 +129,7 @@ int KX_SCA_ReplaceMeshActuator::pyattr_set_mesh(void *self, const struct KX_PYAT KX_MeshProxy* proxy = (KX_MeshProxy*)value; actuator->m_mesh= proxy->GetMesh(); } else { - PyErr_SetString(PyExc_ValueError, "Expected the name of a mesh, a mesh proxy or None"); + PyErr_SetString(PyExc_ValueError, "actuator.mesh = value: Replace Mesh Actuator, expected the mesh name, a KX_MeshProxy or None"); return 1; } return 0; diff --git a/source/gameengine/Ketsji/KX_Scene.cpp b/source/gameengine/Ketsji/KX_Scene.cpp index 96f2f3e8ed3..0e1572da679 100644 --- a/source/gameengine/Ketsji/KX_Scene.cpp +++ b/source/gameengine/Ketsji/KX_Scene.cpp @@ -1678,7 +1678,7 @@ PyObject* KX_Scene::py_getattro(PyObject *attr) Py_INCREF(object); } else { - PyErr_Format(PyExc_AttributeError, "KX_Scene attribute \"%s\" not found", PyString_AsString(attr)); + PyErr_Format(PyExc_AttributeError, "value = scene.myAttr: KX_Scene, attribute \"%s\" not found", PyString_AsString(attr)); } } @@ -1696,7 +1696,7 @@ int KX_Scene::py_setattro(PyObject *attr, PyObject *value) ret= PY_SET_ATTR_SUCCESS; } else { - PyErr_SetString(PyExc_AttributeError, "failed assigning value to KX_Scenes internal dictionary"); + PyErr_SetString(PyExc_AttributeError, "scene.UserAttr = value: KX_Scenes, failed assigning value to internal dictionary"); ret= PY_SET_ATTR_FAIL; } } diff --git a/source/gameengine/Ketsji/KX_SoundActuator.cpp b/source/gameengine/Ketsji/KX_SoundActuator.cpp index eb1d91d760f..b9edd7436df 100644 --- a/source/gameengine/Ketsji/KX_SoundActuator.cpp +++ b/source/gameengine/Ketsji/KX_SoundActuator.cpp @@ -355,7 +355,7 @@ PyObject* KX_SoundActuator::pyattr_get_filename(void *self, const struct KX_PYAT char* name = objectname.Ptr(); if (!name) { - PyErr_SetString(PyExc_RuntimeError, "Unable to get sound filename"); + PyErr_SetString(PyExc_RuntimeError, "value = actuator.filename: KX_SoundActuator, unable to get sound filename"); return NULL; } else return PyString_FromString(name); @@ -541,7 +541,7 @@ int KX_SoundActuator::pyattr_set_orientation(void *self, const struct KX_PYATTRI KX_SoundActuator * actuator = static_cast<KX_SoundActuator *> (self); if (!PySequence_Check(value)) { - PyErr_SetString(PyExc_AttributeError, "'orientation' attribute needs to be a sequence"); + PyErr_SetString(PyExc_AttributeError, "value = actuator.orientation: KX_SoundActuator, expected a sequence"); return 1; } diff --git a/source/gameengine/Ketsji/KX_TouchSensor.cpp b/source/gameengine/Ketsji/KX_TouchSensor.cpp index e7f8acbd1a8..5a6e8e6f501 100644 --- a/source/gameengine/Ketsji/KX_TouchSensor.cpp +++ b/source/gameengine/Ketsji/KX_TouchSensor.cpp @@ -369,7 +369,7 @@ const char KX_TouchSensor::GetTouchMaterial_doc[] = "\tKX_FALSE if it looks for a specific property.\n" ; PyObject* KX_TouchSensor::PyGetTouchMaterial() { - ShowDeprecationWarning("getTouchMaterial()", "the materialCheck property"); + ShowDeprecationWarning("getTouchMaterial()", "the useMaterial property"); return PyInt_FromLong(m_bFindMaterial); } @@ -382,6 +382,7 @@ const char KX_TouchSensor::SetTouchMaterial_doc[] = "\tKX_FALSE to switch off positive pulse mode.\n" ; PyObject* KX_TouchSensor::PySetTouchMaterial(PyObject *value) { + ShowDeprecationWarning("setTouchMaterial()", "the useMaterial property"); int pulseArg = PyInt_AsLong(value); if(pulseArg ==-1 && PyErr_Occurred()) { diff --git a/source/gameengine/Ketsji/KX_VertexProxy.cpp b/source/gameengine/Ketsji/KX_VertexProxy.cpp index 8be125011bb..88f63334285 100644 --- a/source/gameengine/Ketsji/KX_VertexProxy.cpp +++ b/source/gameengine/Ketsji/KX_VertexProxy.cpp @@ -398,7 +398,7 @@ PyObject* KX_VertexProxy::PySetRGBA(PyObject* value) } } - PyErr_SetString(PyExc_TypeError, "expected a 4D vector or an int"); + PyErr_SetString(PyExc_TypeError, "vert.setRGBA(value): KX_VertexProxy, expected a 4D vector or an int"); return NULL; } diff --git a/source/gameengine/VideoTexture/FilterNormal.cpp b/source/gameengine/VideoTexture/FilterNormal.cpp index 03a79c1c8ce..a7266967efb 100644 --- a/source/gameengine/VideoTexture/FilterNormal.cpp +++ b/source/gameengine/VideoTexture/FilterNormal.cpp @@ -74,7 +74,7 @@ static int setColor (PyFilter * self, PyObject * value, void * closure) // check validity of parameter if (value == NULL || !PyInt_Check(value)) { - PyErr_SetString(PyExc_TypeError, "The value must be a int"); + PyErr_SetString(PyExc_TypeError, "filt.colorIdx = int: VideoTexture.FilterNormal, expected the value must be a int"); return -1; } // set color index @@ -94,15 +94,20 @@ static PyObject * getDepth (PyFilter * self, void * closure) static int setDepth (PyFilter * self, PyObject * value, void * closure) { // check validity of parameter - if (value == NULL || !PyFloat_Check(value)) + if (value) { - PyErr_SetString(PyExc_TypeError, "The value must be a float"); - return -1; + float depth= (float)PyFloat_AsDouble(value); + if ((depth==-1 && PyErr_Occurred()) == 0) /* no error converting to a float? */ + { + // set depth + getFilter(self)->setDepth(depth); + // success + return 0; + } } - // set depth - getFilter(self)->setDepth(float(PyFloat_AsDouble(value))); - // success - return 0; + + PyErr_SetString(PyExc_TypeError, "filt.depth = float: VideoTexture.FilterNormal, expected the value must be a float"); + return -1; } diff --git a/source/gameengine/VideoTexture/blendVideoTex.cpp b/source/gameengine/VideoTexture/blendVideoTex.cpp index ec066811a52..c11e7fffecd 100644 --- a/source/gameengine/VideoTexture/blendVideoTex.cpp +++ b/source/gameengine/VideoTexture/blendVideoTex.cpp @@ -1,6 +1,6 @@ /* $Id$ ----------------------------------------------------------------------------- -This source file is part of VideoTexure library +This source file is part of VideoTexture library Copyright (c) 2006 The Zdeno Ash Miklas @@ -49,14 +49,14 @@ static PyObject * getMaterialID (PyObject *self, PyObject *args) char * matName; // get parameters - if (!PyArg_ParseTuple(args, "Os", &obj, &matName)) + if (!PyArg_ParseTuple(args, "Os:materialID", &obj, &matName)) return NULL; // get material id short matID = getMaterialID(obj, matName); // if material was not found, report errot if (matID < 0) { - PyErr_SetString(PyExc_RuntimeError, "object doesn't have material with given name"); + PyErr_SetString(PyExc_RuntimeError, "VideoTexture.materialID(ob, string): Object doesn't have material with given name"); return NULL; } // return material ID @@ -67,7 +67,7 @@ static PyObject * getMaterialID (PyObject *self, PyObject *args) // get last error description static PyObject * getLastError (PyObject *self, PyObject *args) { - return Py_BuildValue("s", Exception::m_lastError.c_str()); + return PyString_FromString(Exception::m_lastError.c_str()); } // set log file @@ -89,7 +89,7 @@ static PyObject * imageToArray (PyObject * self, PyObject *args) if (!PyArg_ParseTuple(args, "O", &pyImg) || !pyImageTypes.in(pyImg->ob_type)) { // if object is incorect, report error - PyErr_SetString(PyExc_TypeError, "The value must be a image source object"); + PyErr_SetString(PyExc_TypeError, "VideoTexture.imageToArray(image): The value must be a image source object"); return NULL; } // get image structure |