Replace direct uses of ob_type, which gives problems in nogil build
This commit is contained in:
parent
10da05e2a6
commit
64454b1c9f
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue