From 749b23a190d7159641440f918b0f6e2f82de8e65 Mon Sep 17 00:00:00 2001 From: rdb Date: Sat, 25 Nov 2017 23:12:47 +0100 Subject: [PATCH] Fix support for pickling NodePaths (broken in 1b1d80c) Fixes: #199 --- panda/src/pgraph/nodePath_ext.cxx | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/panda/src/pgraph/nodePath_ext.cxx b/panda/src/pgraph/nodePath_ext.cxx index e9a9406223..5b63c896ff 100644 --- a/panda/src/pgraph/nodePath_ext.cxx +++ b/panda/src/pgraph/nodePath_ext.cxx @@ -130,7 +130,7 @@ __reduce_persist__(PyObject *self, PyObject *pickler) const { } // Start by getting this class object. - PyObject *this_class = PyObject_Type(self); + PyObject *this_class = (PyObject *)Py_TYPE(self); if (this_class == NULL) { return NULL; } @@ -143,7 +143,6 @@ __reduce_persist__(PyObject *self, PyObject *pickler) const { func = Extension::find_global_decode(this_class, "py_decode_NodePath_from_bam_stream_persist"); if (func == NULL) { PyErr_SetString(PyExc_TypeError, "Couldn't find py_decode_NodePath_from_bam_stream_persist()"); - Py_DECREF(this_class); return NULL; } @@ -153,15 +152,13 @@ __reduce_persist__(PyObject *self, PyObject *pickler) const { func = Extension::find_global_decode(this_class, "py_decode_NodePath_from_bam_stream"); if (func == NULL) { PyErr_SetString(PyExc_TypeError, "Couldn't find py_decode_NodePath_from_bam_stream()"); - Py_DECREF(this_class); return NULL; } } // PyTuple_SET_ITEM conveniently borrows the reference it is passed. - PyObject *args = PyTuple_New(2); - PyTuple_SET_ITEM(args, 0, this_class); - PyTuple_SET_ITEM(args, 1, Dtool_WrapValue(bam_stream)); + PyObject *args = PyTuple_New(1); + PyTuple_SET_ITEM(args, 0, Dtool_WrapValue(bam_stream)); PyObject *tuple = PyTuple_New(2); PyTuple_SET_ITEM(tuple, 0, func);