Browse Source

Replace direct uses of ob_type, which gives problems in nogil build

rdb 1 year ago
parent
commit
64454b1c9f

+ 3 - 2
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);

+ 1 - 1
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
 

+ 1 - 1
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;
     }

+ 1 - 1
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;
     }

+ 1 - 1
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;
     }

+ 1 - 1
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) {

+ 1 - 1
panda/src/ode/odeUtil_ext.cxx

@@ -28,7 +28,7 @@ int Extension<OdeUtil>::
 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;

+ 1 - 1
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;
   }