Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2013-05-03 05:13:51 +0400
committerCampbell Barton <ideasman42@gmail.com>2013-05-03 05:13:51 +0400
commit854fd940165736db01eeff05719f1a60a6a89a8b (patch)
treef3269fc7c96cf8f8b685ec9fde379504609a6988 /source/gameengine/Ketsji/KX_GameObject.cpp
parentd92bd6bb0421ff98b209aba3aac34edfd1a08ab3 (diff)
bge py api: raise an overflow exception when assigning a float to a bge object which is out of the float range.
also avoid raising exceptions by ConvertPythonToValue when they will be ignored.
Diffstat (limited to 'source/gameengine/Ketsji/KX_GameObject.cpp')
-rw-r--r--source/gameengine/Ketsji/KX_GameObject.cpp21
1 files changed, 10 insertions, 11 deletions
diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp b/source/gameengine/Ketsji/KX_GameObject.cpp
index 172440cfcb6..f52ee0c42c3 100644
--- a/source/gameengine/Ketsji/KX_GameObject.cpp
+++ b/source/gameengine/Ketsji/KX_GameObject.cpp
@@ -1858,15 +1858,14 @@ static int Map_SetItem(PyObject *self_v, PyObject *key, PyObject *val)
}
}
else { /* ob["key"] = value */
- int set= 0;
+ bool set = false;
/* as CValue */
if (attr_str && PyObject_TypeCheck(val, &PyObjectPlus::Type)==0) /* don't allow GameObjects for eg to be assigned to CValue props */
{
- CValue* vallie = self->ConvertPythonToValue(val, ""); /* error unused */
+ CValue *vallie = self->ConvertPythonToValue(val, false, "gameOb[key] = value: ");
- if (vallie)
- {
+ if (vallie) {
CValue* oldprop = self->GetProperty(attr_str);
if (oldprop)
@@ -1875,7 +1874,7 @@ static int Map_SetItem(PyObject *self_v, PyObject *key, PyObject *val)
self->SetProperty(attr_str, vallie);
vallie->Release();
- set= 1;
+ set = true;
/* try remove dict value to avoid double ups */
if (self->m_attr_dict) {
@@ -1883,13 +1882,12 @@ static int Map_SetItem(PyObject *self_v, PyObject *key, PyObject *val)
PyErr_Clear();
}
}
- else {
- PyErr_Clear();
+ else if (PyErr_Occurred()) {
+ return -1;
}
}
- if (set==0)
- {
+ if (set == false) {
if (self->m_attr_dict==NULL) /* lazy init */
self->m_attr_dict= PyDict_New();
@@ -1898,7 +1896,7 @@ static int Map_SetItem(PyObject *self_v, PyObject *key, PyObject *val)
{
if (attr_str)
self->RemoveProperty(attr_str); /* overwrite the CValue if it exists */
- set= 1;
+ set = true;
}
else {
if (attr_str) PyErr_Format(PyExc_KeyError, "gameOb[key] = value: KX_GameObject, key \"%s\" not be added to internal dictionary", attr_str);
@@ -1906,8 +1904,9 @@ static int Map_SetItem(PyObject *self_v, PyObject *key, PyObject *val)
}
}
- if (set==0)
+ if (set == false) {
return -1; /* pythons error value */
+ }
}