diff --git a/direct/src/dcparser/dcField.cxx b/direct/src/dcparser/dcField.cxx index 5880fd5097..80cb211f40 100644 --- a/direct/src/dcparser/dcField.cxx +++ b/direct/src/dcparser/dcField.cxx @@ -538,8 +538,9 @@ get_pystr(PyObject *value) { return result; } - if (value->ob_type != nullptr) { - PyObject *typestr = PyObject_Str((PyObject *)(value->ob_type)); + PyTypeObject *type = Py_TYPE(value); + if (type != nullptr) { + PyObject *typestr = PyObject_Str((PyObject *)type); if (typestr != nullptr) { #if PY_MAJOR_VERSION >= 3 string result = PyUnicode_AsUTF8(typestr); diff --git a/dtool/src/interrogatedb/py_compat.h b/dtool/src/interrogatedb/py_compat.h index a386c06136..65ef2ec39a 100644 --- a/dtool/src/interrogatedb/py_compat.h +++ b/dtool/src/interrogatedb/py_compat.h @@ -65,7 +65,7 @@ typedef int Py_ssize_t; /* Python 2.6 */ -#ifndef Py_TYPE +#if PY_VERSION_HEX < 0x02060000 # define Py_TYPE(ob) (((PyObject*)(ob))->ob_type) #endif diff --git a/panda/src/linmath/lvecBase2_ext_src.I b/panda/src/linmath/lvecBase2_ext_src.I index edb0a69af6..4fea21a1df 100644 --- a/panda/src/linmath/lvecBase2_ext_src.I +++ b/panda/src/linmath/lvecBase2_ext_src.I @@ -188,7 +188,7 @@ __setattr__(PyObject *self, const std::string &attr_name, PyObject *assign) { #endif } else { PyErr_Format(PyExc_ValueError, "'%.200s' object is not iterable", - assign->ob_type->tp_name); + Py_TYPE(assign)->tp_name); } return -1; } diff --git a/panda/src/linmath/lvecBase3_ext_src.I b/panda/src/linmath/lvecBase3_ext_src.I index 72913c816c..67b7f8d21f 100644 --- a/panda/src/linmath/lvecBase3_ext_src.I +++ b/panda/src/linmath/lvecBase3_ext_src.I @@ -192,7 +192,7 @@ __setattr__(PyObject *self, const std::string &attr_name, PyObject *assign) { #endif } else { PyErr_Format(PyExc_ValueError, "'%.200s' object is not iterable", - assign->ob_type->tp_name); + Py_TYPE(assign)->tp_name); } return -1; } diff --git a/panda/src/linmath/lvecBase4_ext_src.I b/panda/src/linmath/lvecBase4_ext_src.I index 1a120e678d..013a921e73 100644 --- a/panda/src/linmath/lvecBase4_ext_src.I +++ b/panda/src/linmath/lvecBase4_ext_src.I @@ -201,7 +201,7 @@ __setattr__(PyObject *self, const std::string &attr_name, PyObject *assign) { #endif } else { PyErr_Format(PyExc_ValueError, "'%.200s' object is not iterable", - assign->ob_type->tp_name); + Py_TYPE(assign)->tp_name); } return -1; } diff --git a/panda/src/ode/odeSpace_ext.cxx b/panda/src/ode/odeSpace_ext.cxx index 97e841f30b..e1c5754bc8 100644 --- a/panda/src/ode/odeSpace_ext.cxx +++ b/panda/src/ode/odeSpace_ext.cxx @@ -72,7 +72,7 @@ collide(PyObject* arg, PyObject* callback) { nassertr(callback != nullptr, -1); if (!PyCallable_Check(callback)) { - PyErr_Format(PyExc_TypeError, "'%s' object is not callable", callback->ob_type->tp_name); + PyErr_Format(PyExc_TypeError, "'%s' object is not callable", Py_TYPE(callback)->tp_name); return -1; } else if (_this->get_id() == nullptr) { diff --git a/panda/src/ode/odeUtil_ext.cxx b/panda/src/ode/odeUtil_ext.cxx index c5aabaa812..ea04dc0a45 100644 --- a/panda/src/ode/odeUtil_ext.cxx +++ b/panda/src/ode/odeUtil_ext.cxx @@ -28,7 +28,7 @@ int Extension:: collide2(const OdeGeom &geom1, const OdeGeom &geom2, PyObject* arg, PyObject* callback) { nassertr(callback != nullptr, -1); if (!PyCallable_Check(callback)) { - PyErr_Format(PyExc_TypeError, "'%s' object is not callable", callback->ob_type->tp_name); + PyErr_Format(PyExc_TypeError, "'%s' object is not callable", Py_TYPE(callback)->tp_name); return -1; } else { _python_callback = (PyObject*) callback; diff --git a/panda/src/pgraph/nodePathCollection_ext.cxx b/panda/src/pgraph/nodePathCollection_ext.cxx index 836e2959e0..dee4fede7a 100644 --- a/panda/src/pgraph/nodePathCollection_ext.cxx +++ b/panda/src/pgraph/nodePathCollection_ext.cxx @@ -75,7 +75,7 @@ __reduce__(PyObject *self) const { // object whose constructor we should call (e.g. this), and the arguments // necessary to reconstruct this object. - PyObject *this_class = (PyObject *)self->ob_type; + PyObject *this_class = (PyObject *)Py_TYPE(self); if (this_class == nullptr) { return nullptr; }