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.
This commit is contained in:
@@ -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 */
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user