mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-01 01:07:51 -04:00
better handling when getter doesn't return a tuple
This commit is contained in:
parent
2657a91ae0
commit
a642a9d756
@ -620,6 +620,18 @@ pack_required_field(DCPacker &packer, PyObject *distobj,
|
|||||||
PyObject *tuple = PyTuple_New(1);
|
PyObject *tuple = PyTuple_New(1);
|
||||||
PyTuple_SET_ITEM(tuple, 0, result);
|
PyTuple_SET_ITEM(tuple, 0, result);
|
||||||
result = tuple;
|
result = tuple;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
// Otherwise, it had better already be a sequence or tuple of some
|
||||||
|
// sort.
|
||||||
|
if (!PySequence_Check(result)) {
|
||||||
|
ostringstream strm;
|
||||||
|
strm << "Since dclass " << get_name() << " method " << setter_name
|
||||||
|
<< " is declared to have multiple parameters, Python function "
|
||||||
|
<< getter_name << " must return a list or tuple.\n";
|
||||||
|
nassert_raise(strm.str());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now pack the arguments into the datagram.
|
// Now pack the arguments into the datagram.
|
||||||
|
@ -419,20 +419,30 @@ pack_args(DCPacker &packer, PyObject *sequence) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!Notify::ptr()->has_assert_failed()) {
|
if (!Notify::ptr()->has_assert_failed()) {
|
||||||
PyObject *tuple = PySequence_Tuple(sequence);
|
|
||||||
PyObject *str = PyObject_Str(tuple);
|
|
||||||
|
|
||||||
ostringstream strm;
|
ostringstream strm;
|
||||||
if (packer.had_pack_error()) {
|
|
||||||
strm << "Incorrect arguments to field: " << get_name()
|
|
||||||
<< PyString_AsString(str);
|
|
||||||
} else {
|
|
||||||
strm << "Value out of range on field: " << get_name()
|
|
||||||
<< PyString_AsString(str);
|
|
||||||
}
|
|
||||||
|
|
||||||
Py_DECREF(str);
|
PyObject *tuple = PySequence_Tuple(sequence);
|
||||||
Py_DECREF(tuple);
|
if (tuple == (PyObject *)NULL) {
|
||||||
|
PyObject *str = PyObject_Str(sequence);
|
||||||
|
nassertr(str != (PyObject *)NULL, false);
|
||||||
|
strm << "Arguments to field " << get_name()
|
||||||
|
<< " not a sequence: " << PyString_AsString(str);
|
||||||
|
Py_DECREF(str);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
PyObject *str = PyObject_Str(tuple);
|
||||||
|
|
||||||
|
if (packer.had_pack_error()) {
|
||||||
|
strm << "Incorrect arguments to field: " << get_name()
|
||||||
|
<< PyString_AsString(str);
|
||||||
|
} else {
|
||||||
|
strm << "Value out of range on field: " << get_name()
|
||||||
|
<< PyString_AsString(str);
|
||||||
|
}
|
||||||
|
|
||||||
|
Py_DECREF(str);
|
||||||
|
Py_DECREF(tuple);
|
||||||
|
}
|
||||||
|
|
||||||
nassert_raise(strm.str());
|
nassert_raise(strm.str());
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user