From 263ebe9ca86086b3b8ad52bcbab69b7437dcab6e Mon Sep 17 00:00:00 2001 From: David Rose Date: Wed, 4 Aug 2004 21:32:31 +0000 Subject: [PATCH] don't unpack to python obejct if no method to receive it --- direct/src/dcparser/dcField.cxx | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/direct/src/dcparser/dcField.cxx b/direct/src/dcparser/dcField.cxx index 8c2f189e80..8117a7210d 100644 --- a/direct/src/dcparser/dcField.cxx +++ b/direct/src/dcparser/dcField.cxx @@ -464,10 +464,18 @@ unpack_args(DCPacker &packer) const { //////////////////////////////////////////////////////////////////// void DCField:: receive_update(DCPacker &packer, PyObject *distobj) const { - PyObject *args = unpack_args(packer); + if (!PyObject_HasAttrString(distobj, (char *)_name.c_str())) { + // If there's no Python method to receive this message, don't + // bother unpacking it to a Python tuple--just skip past the + // message. + packer.unpack_skip(); - if (args != (PyObject *)NULL) { - if (PyObject_HasAttrString(distobj, (char *)_name.c_str())) { + } else { + // Otherwise, get a Python tuple from the args and call the Python + // method. + PyObject *args = unpack_args(packer); + + if (args != (PyObject *)NULL) { PyObject *func = PyObject_GetAttrString(distobj, (char *)_name.c_str()); nassertv(func != (PyObject *)NULL);