Replace direct access to PyObject.ob_type with Py_TYPE().
if (rv == 0) {
PyErr_Format(PyExc_TypeError,
"can only concatenate deque (not \"%.200s\") to deque",
- other->ob_type->tp_name);
+ Py_TYPE(other)->tp_name);
}
return NULL;
}
"descriptor for index '%zd' for tuple subclasses "
"doesn't apply to '%s' object",
index,
- obj->ob_type->tp_name);
+ Py_TYPE(obj)->tp_name);
return NULL;
}
if (!PyUnicode_Check(src)) {
PyErr_Format(PyExc_TypeError,
"\"%s\" must be string, not %.200s", name,
- src->ob_type->tp_name);
+ Py_TYPE(src)->tp_name);
return -1;
}
len = PyUnicode_GetLength(src);
"iterator should return strings, "
"not %.200s "
"(did you open the file in text mode?)",
- lineobj->ob_type->tp_name
+ Py_TYPE(lineobj)->tp_name
);
Py_DECREF(lineobj);
return NULL;
if (iter == NULL)
return PyErr_Format(_csvstate_global->error_obj,
"iterable expected, not %.200s",
- seq->ob_type->tp_name);
+ Py_TYPE(seq)->tp_name);
/* Join all fields in internal buffer.
*/
PyCField_dealloc(PyObject *self)
{
PyCField_clear((CFieldObject *)self);
- self->ob_type->tp_free((PyObject *)self);
+ Py_TYPE(self)->tp_free((PyObject *)self);
}
static PyObject *
if (!PyUnicode_Check(value)) {
PyErr_Format(PyExc_TypeError,
"unicode string expected instead of %s instance",
- value->ob_type->tp_name);
+ Py_TYPE(value)->tp_name);
return NULL;
} else
Py_INCREF(value);
if (!PyUnicode_Check(value)) {
PyErr_Format(PyExc_TypeError,
"unicode string expected instead of %s instance",
- value->ob_type->tp_name);
+ Py_TYPE(value)->tp_name);
return NULL;
}
if(!PyBytes_Check(value)) {
PyErr_Format(PyExc_TypeError,
"expected bytes, %s found",
- value->ob_type->tp_name);
+ Py_TYPE(value)->tp_name);
return NULL;
}
}
PyErr_Format(PyExc_TypeError,
"bytes or integer address expected instead of %s instance",
- value->ob_type->tp_name);
+ Py_TYPE(value)->tp_name);
return NULL;
}
if (!PyUnicode_Check(value)) {
PyErr_Format(PyExc_TypeError,
"unicode string or integer address expected instead of %s instance",
- value->ob_type->tp_name);
+ Py_TYPE(value)->tp_name);
return NULL;
}
} else if (!PyUnicode_Check(value)) {
PyErr_Format(PyExc_TypeError,
"unicode string expected instead of %s instance",
- value->ob_type->tp_name);
+ Py_TYPE(value)->tp_name);
return NULL;
}
} PyCFuncPtrObject;
extern PyTypeObject PyCStgDict_Type;
-#define PyCStgDict_CheckExact(v) ((v)->ob_type == &PyCStgDict_Type)
+#define PyCStgDict_CheckExact(v) (Py_TYPE(v) == &PyCStgDict_Type)
#define PyCStgDict_Check(v) PyObject_TypeCheck(v, &PyCStgDict_Type)
extern int PyCStructUnionType_update_stgdict(PyObject *fields, PyObject *type, int isStruct);
};
extern PyTypeObject PyCArg_Type;
-#define PyCArg_CheckExact(v) ((v)->ob_type == &PyCArg_Type)
+#define PyCArg_CheckExact(v) (Py_TYPE(v) == &PyCArg_Type)
extern PyCArgObject *PyCArgObject_new(void);
extern PyObject *
StgDictObject *
PyObject_stgdict(PyObject *self)
{
- PyTypeObject *type = self->ob_type;
+ PyTypeObject *type = Py_TYPE(self);
if (!type->tp_dict || !PyCStgDict_CheckExact(type->tp_dict))
return NULL;
return (StgDictObject *)type->tp_dict;
if (!PyBytes_Check(data)) {
PyErr_Format(PyExc_TypeError,
"f.read() returned %.100s instead of bytes",
- data->ob_type->tp_name);
+ Py_TYPE(data)->tp_name);
Py_DECREF(data);
goto error;
}
if (!PyTuple_Check(result)) {
PyErr_Format(PyExc_TypeError,
"divmod() returned non-tuple (type %.200s)",
- result->ob_type->tp_name);
+ Py_TYPE(result)->tp_name);
Py_DECREF(result);
return NULL;
}
else if (!PyBytes_Check(arg)) {
PyErr_Format(PyExc_TypeError,
"dbm key must be bytes or string, not %.100s",
- arg->ob_type->tp_name);
+ Py_TYPE(arg)->tp_name);
return -1;
}
else {
else {
PyErr_Format(PyExc_TypeError,
"conversion from %s to Decimal is not supported",
- v->ob_type->tp_name);
+ Py_TYPE(v)->tp_name);
return NULL;
}
}
else {
PyErr_Format(PyExc_TypeError,
"conversion from %s to Decimal is not supported",
- v->ob_type->tp_name);
+ Py_TYPE(v)->tp_name);
return NULL;
}
}
if (type_err) {
PyErr_Format(PyExc_TypeError,
"conversion from %s to Decimal is not supported",
- v->ob_type->tp_name);
+ Py_TYPE(v)->tp_name);
}
else {
Py_INCREF(Py_NotImplemented);
else if (!PyBytes_Check(arg)) {
PyErr_Format(PyExc_TypeError,
"gdbm key must be bytes or string, not %.100s",
- arg->ob_type->tp_name);
+ Py_TYPE(arg)->tp_name);
return -1;
}
else {
/* Otherwise replace the error with caller's error object. */
PyErr_Format(err,
"cannot fit '%.200s' into an offset-sized integer",
- item->ob_type->tp_name);
+ Py_TYPE(item)->tp_name);
}
finish:
PyErr_Format(
PyExc_TypeError,
"TextIOWrapper() argument 'errors' must be str or None, not %.50s",
- errors->ob_type->tp_name);
+ Py_TYPE(errors)->tp_name);
return -1;
}
else if (io_check_errors(errors)) {
else {
PyErr_Format(PyExc_TypeError,
"keys must be str, int, float, bool or None, "
- "not %.100s", key->ob_type->tp_name);
+ "not %.100s", Py_TYPE(key)->tp_name);
goto bail;
}
PyErr_Format(PyExc_ValueError,
"fast mode: can't pickle cyclic objects "
"including object type %.200s at %p",
- obj->ob_type->tp_name, obj);
+ Py_TYPE(obj)->tp_name, obj);
self->fast_nesting = -1;
return 0;
}
way to get a quotable object to be its instance */
/* look for an adapter in the registry */
- key = Py_BuildValue("(OO)", (PyObject*)obj->ob_type, proto);
+ key = Py_BuildValue("(OO)", (PyObject*)Py_TYPE(obj), proto);
if (!key) {
return NULL;
}
type_error:
PyErr_Format(PyExc_TypeError,
"cannot index memory using \"%.200s\"",
- key->ob_type->tp_name);
+ Py_TYPE(key)->tp_name);
err_occurred:
Py_DECREF(nd);
return NULL;
if (!PyDict_Check(arg)) {
PyErr_Format(PyExc_TypeError,
"dict_hassplittable() argument must be dict, not '%s'",
- arg->ob_type->tp_name);
+ Py_TYPE(arg)->tp_name);
return NULL;
}
if (!PyCallable_Check(fn)) {
PyErr_Format(PyExc_TypeError, "'%s' object is not callable",
- fn->ob_type->tp_name);
+ Py_TYPE(fn)->tp_name);
return NULL;
}
} PyTclObject;
static PyObject *PyTclObject_Type;
-#define PyTclObject_Check(v) ((v)->ob_type == (PyTypeObject *) PyTclObject_Type)
+#define PyTclObject_Check(v) (Py_TYPE(v) == (PyTypeObject *) PyTclObject_Type)
static PyObject *
newPyTclObject(Tcl_Obj *arg)
}
PyErr_Format(PyExc_TypeError,
"must be str, bytes or Tcl_Obj, not %.50s",
- in->ob_type->tp_name);
+ Py_TYPE(in)->tp_name);
return 0;
}
else {
PyErr_Format(PyExc_TypeError,
"channel ID must be an int, got %.100s",
- arg->ob_type->tp_name);
+ Py_TYPE(arg)->tp_name);
return 0;
}
*(int64_t *)ptr = cid;
PyErr_Format(PyExc_TypeError,
"stream function returned a "
"non-bytes object (%.100s)",
- cres->ob_type->tp_name);
+ Py_TYPE(cres)->tp_name);
goto errorexit;
}
MultibyteCodec *codec;
} MultibyteCodecObject;
-#define MultibyteCodec_Check(op) ((op)->ob_type == &MultibyteCodec_Type)
+#define MultibyteCodec_Check(op) (Py_TYPE(op) == &MultibyteCodec_Type)
#define _MultibyteStatefulCodec_HEAD \
PyObject_HEAD \
static int
has_legacy_finalizer(PyObject *op)
{
- return op->ob_type->tp_del != NULL;
+ return Py_TYPE(op)->tp_del != NULL;
}
/* Move the objects in unreachable with tp_del slots into `finalizers`.
PyErr_Clear();
if (PyErr_WarnFormat(PyExc_DeprecationWarning, 1,
"group id must be int, not %.200",
- id->ob_type->tp_name) < 0) {
+ Py_TYPE(id)->tp_name) < 0) {
return NULL;
}
py_int_id = PyNumber_Long(id);
/* PyST_Type isn't subclassable, so just check ob_type */
-#define PyST_Object_Check(v) ((v)->ob_type == &PyST_Type)
+#define PyST_Object_Check(v) (Py_TYPE(v) == &PyST_Type)
static int
parser_compare_nodes(node *left, node *right)
{
SHAobject *newobj;
- if (((PyObject*)self)->ob_type == &SHA512type) {
+ if (Py_TYPE((PyObject*)self) == &SHA512type) {
if ( (newobj = newSHA512object())==NULL)
return NULL;
} else {
}
else {
PyErr_Format(PyExc_TypeError, "str, bytes or bytearray expected, not %s",
- obj->ob_type->tp_name);
+ Py_TYPE(obj)->tp_name);
return 0;
}
if (strlen(data->buf) != len) {