better fix for crash

This commit is contained in:
David Rose 2005-07-13 00:32:39 +00:00
parent e7857739d5
commit effdbb24af

View File

@ -863,10 +863,17 @@ unpack_object() {
// valid constructor, create the class object instead of // valid constructor, create the class object instead of
// just a tuple. // just a tuple.
object = unpack_class_object(dclass); object = unpack_class_object(dclass);
break; if (object == (PyObject *)NULL) {
cerr << "Unable to construct object of class "
<< dclass->get_name() << "\n";
} else {
break;
}
} }
} }
} }
// Fall through (if no constructor)
// If we don't know what kind of class object it is, or it doesn't // If we don't know what kind of class object it is, or it doesn't
// have a constructor, fall through and make a tuple. // have a constructor, fall through and make a tuple.
default: default:
@ -878,7 +885,7 @@ unpack_object() {
while (more_nested_fields()) { while (more_nested_fields()) {
PyObject *element = unpack_object(); PyObject *element = unpack_object();
PyList_Append(object, element); PyList_Append(object, element);
Py_XDECREF(element); Py_DECREF(element);
} }
pop(); pop();
@ -893,6 +900,7 @@ unpack_object() {
break; break;
} }
nassertr(object != (PyObject *)NULL, Py_None);
return object; return object;
} }
#endif // HAVE_PYTHON #endif // HAVE_PYTHON