#1629: Renamed Py_Size, Py_Type and Py_Refcnt to Py_SIZE, Py_TYPE and Py_REFCNT.

This commit is contained in:
Christian Heimes 2007-12-19 02:45:37 +00:00
parent 99170a5dbf
commit 90aa7646af
144 changed files with 1306 additions and 1153 deletions

View file

@ -60,7 +60,7 @@ type_set_name(PyTypeObject *type, PyObject *value, void *context)
if (!PyUnicode_Check(value)) {
PyErr_Format(PyExc_TypeError,
"can only assign string to %s.__name__, not '%s'",
type->tp_name, Py_Type(value)->tp_name);
type->tp_name, Py_TYPE(value)->tp_name);
return -1;
}
@ -216,7 +216,7 @@ type_set_bases(PyTypeObject *type, PyObject *value, void *context)
if (!PyTuple_Check(value)) {
PyErr_Format(PyExc_TypeError,
"can only assign tuple to %s.__bases__, not %s",
type->tp_name, Py_Type(value)->tp_name);
type->tp_name, Py_TYPE(value)->tp_name);
return -1;
}
if (PyTuple_GET_SIZE(value) == 0) {
@ -231,7 +231,7 @@ type_set_bases(PyTypeObject *type, PyObject *value, void *context)
PyErr_Format(
PyExc_TypeError,
"%s.__bases__ must be tuple of old- or new-style classes, not '%s'",
type->tp_name, Py_Type(ob)->tp_name);
type->tp_name, Py_TYPE(ob)->tp_name);
return -1;
}
if (PyType_Check(ob)) {
@ -356,8 +356,8 @@ type_get_doc(PyTypeObject *type, void *context)
result = Py_None;
Py_INCREF(result);
}
else if (Py_Type(result)->tp_descr_get) {
result = Py_Type(result)->tp_descr_get(result, NULL,
else if (Py_TYPE(result)->tp_descr_get) {
result = Py_TYPE(result)->tp_descr_get(result, NULL,
(PyObject *)type);
}
else {
@ -430,9 +430,9 @@ type_call(PyTypeObject *type, PyObject *args, PyObject *kwds)
return obj;
/* If the returned object is not an instance of type,
it won't be initialized. */
if (!PyType_IsSubtype(Py_Type(obj), type))
if (!PyType_IsSubtype(Py_TYPE(obj), type))
return obj;
type = Py_Type(obj);
type = Py_TYPE(obj);
if (type->tp_init != NULL &&
type->tp_init(obj, args, kwds) < 0) {
Py_DECREF(obj);
@ -486,7 +486,7 @@ traverse_slots(PyTypeObject *type, PyObject *self, visitproc visit, void *arg)
Py_ssize_t i, n;
PyMemberDef *mp;
n = Py_Size(type);
n = Py_SIZE(type);
mp = PyHeapType_GET_MEMBERS((PyHeapTypeObject *)type);
for (i = 0; i < n; i++, mp++) {
if (mp->type == T_OBJECT_EX) {
@ -510,10 +510,10 @@ subtype_traverse(PyObject *self, visitproc visit, void *arg)
/* Find the nearest base with a different tp_traverse,
and traverse slots while we're at it */
type = Py_Type(self);
type = Py_TYPE(self);
base = type;
while ((basetraverse = base->tp_traverse) == subtype_traverse) {
if (Py_Size(base)) {
if (Py_SIZE(base)) {
int err = traverse_slots(base, self, visit, arg);
if (err)
return err;
@ -545,7 +545,7 @@ clear_slots(PyTypeObject *type, PyObject *self)
Py_ssize_t i, n;
PyMemberDef *mp;
n = Py_Size(type);
n = Py_SIZE(type);
mp = PyHeapType_GET_MEMBERS((PyHeapTypeObject *)type);
for (i = 0; i < n; i++, mp++) {
if (mp->type == T_OBJECT_EX && !(mp->flags & READONLY)) {
@ -567,10 +567,10 @@ subtype_clear(PyObject *self)
/* Find the nearest base with a different tp_clear
and clear slots while we're at it */
type = Py_Type(self);
type = Py_TYPE(self);
base = type;
while ((baseclear = base->tp_clear) == subtype_clear) {
if (Py_Size(base))
if (Py_SIZE(base))
clear_slots(base, self);
base = base->tp_base;
assert(base);
@ -591,7 +591,7 @@ subtype_dealloc(PyObject *self)
destructor basedealloc;
/* Extract the type; we expect it to be a heap type */
type = Py_Type(self);
type = Py_TYPE(self);
assert(type->tp_flags & Py_TPFLAGS_HEAPTYPE);
/* Test whether the type has GC exactly once */
@ -613,7 +613,7 @@ subtype_dealloc(PyObject *self)
/* Find the nearest base with a different tp_dealloc */
base = type;
while ((basedealloc = base->tp_dealloc) == subtype_dealloc) {
assert(Py_Size(base) == 0);
assert(Py_SIZE(base) == 0);
base = base->tp_base;
assert(base);
}
@ -681,7 +681,7 @@ subtype_dealloc(PyObject *self)
/* Clear slots up to the nearest base with a different tp_dealloc */
base = type;
while ((basedealloc = base->tp_dealloc) == subtype_dealloc) {
if (Py_Size(base))
if (Py_SIZE(base))
clear_slots(base, self);
base = base->tp_base;
assert(base);
@ -872,13 +872,13 @@ lookup_maybe(PyObject *self, char *attrstr, PyObject **attrobj)
if (*attrobj == NULL)
return NULL;
}
res = _PyType_Lookup(Py_Type(self), *attrobj);
res = _PyType_Lookup(Py_TYPE(self), *attrobj);
if (res != NULL) {
descrgetfunc f;
if ((f = Py_Type(res)->tp_descr_get) == NULL)
if ((f = Py_TYPE(res)->tp_descr_get) == NULL)
Py_INCREF(res);
else
res = f(res, self, (PyObject *)(Py_Type(self)));
res = f(res, self, (PyObject *)(Py_TYPE(self)));
}
return res;
}
@ -1251,7 +1251,7 @@ mro_internal(PyTypeObject *type)
PyObject *mro, *result, *tuple;
int checkit = 0;
if (Py_Type(type) == &PyType_Type) {
if (Py_TYPE(type) == &PyType_Type) {
result = mro_implementation(type);
}
else {
@ -1284,7 +1284,7 @@ mro_internal(PyTypeObject *type)
if (!PyType_Check(cls)) {
PyErr_Format(PyExc_TypeError,
"mro() returned a non-class ('%.500s')",
Py_Type(cls)->tp_name);
Py_TYPE(cls)->tp_name);
Py_DECREF(tuple);
return -1;
}
@ -1440,7 +1440,7 @@ raise_dict_descr_error(PyObject *obj)
{
PyErr_Format(PyExc_TypeError,
"this __dict__ descriptor does not support "
"'%.200s' objects", Py_Type(obj)->tp_name);
"'%.200s' objects", Py_TYPE(obj)->tp_name);
}
static PyObject *
@ -1450,7 +1450,7 @@ subtype_dict(PyObject *obj, void *context)
PyObject *dict;
PyTypeObject *base;
base = get_builtin_base_with_dict(Py_Type(obj));
base = get_builtin_base_with_dict(Py_TYPE(obj));
if (base != NULL) {
descrgetfunc func;
PyObject *descr = get_dict_descriptor(base);
@ -1458,12 +1458,12 @@ subtype_dict(PyObject *obj, void *context)
raise_dict_descr_error(obj);
return NULL;
}
func = Py_Type(descr)->tp_descr_get;
func = Py_TYPE(descr)->tp_descr_get;
if (func == NULL) {
raise_dict_descr_error(obj);
return NULL;
}
return func(descr, obj, (PyObject *)(Py_Type(obj)));
return func(descr, obj, (PyObject *)(Py_TYPE(obj)));
}
dictptr = _PyObject_GetDictPtr(obj);
@ -1486,7 +1486,7 @@ subtype_setdict(PyObject *obj, PyObject *value, void *context)
PyObject *dict;
PyTypeObject *base;
base = get_builtin_base_with_dict(Py_Type(obj));
base = get_builtin_base_with_dict(Py_TYPE(obj));
if (base != NULL) {
descrsetfunc func;
PyObject *descr = get_dict_descriptor(base);
@ -1494,7 +1494,7 @@ subtype_setdict(PyObject *obj, PyObject *value, void *context)
raise_dict_descr_error(obj);
return -1;
}
func = Py_Type(descr)->tp_descr_set;
func = Py_TYPE(descr)->tp_descr_set;
if (func == NULL) {
raise_dict_descr_error(obj);
return -1;
@ -1511,7 +1511,7 @@ subtype_setdict(PyObject *obj, PyObject *value, void *context)
if (value != NULL && !PyDict_Check(value)) {
PyErr_Format(PyExc_TypeError,
"__dict__ must be set to a dictionary, "
"not a '%.200s'", Py_Type(value)->tp_name);
"not a '%.200s'", Py_TYPE(value)->tp_name);
return -1;
}
dict = *dictptr;
@ -1527,16 +1527,16 @@ subtype_getweakref(PyObject *obj, void *context)
PyObject **weaklistptr;
PyObject *result;
if (Py_Type(obj)->tp_weaklistoffset == 0) {
if (Py_TYPE(obj)->tp_weaklistoffset == 0) {
PyErr_SetString(PyExc_AttributeError,
"This object has no __weakref__");
return NULL;
}
assert(Py_Type(obj)->tp_weaklistoffset > 0);
assert(Py_Type(obj)->tp_weaklistoffset + sizeof(PyObject *) <=
(size_t)(Py_Type(obj)->tp_basicsize));
assert(Py_TYPE(obj)->tp_weaklistoffset > 0);
assert(Py_TYPE(obj)->tp_weaklistoffset + sizeof(PyObject *) <=
(size_t)(Py_TYPE(obj)->tp_basicsize));
weaklistptr = (PyObject **)
((char *)obj + Py_Type(obj)->tp_weaklistoffset);
((char *)obj + Py_TYPE(obj)->tp_weaklistoffset);
if (*weaklistptr == NULL)
result = Py_None;
else
@ -1573,7 +1573,7 @@ valid_identifier(PyObject *s)
if (!PyUnicode_Check(s)) {
PyErr_Format(PyExc_TypeError,
"__slots__ items must be strings, not '%.200s'",
Py_Type(s)->tp_name);
Py_TYPE(s)->tp_name);
return 0;
}
if (!PyUnicode_IsIdentifier(s)) {
@ -1639,8 +1639,8 @@ type_new(PyTypeObject *metatype, PyObject *args, PyObject *kwds)
if (PyType_CheckExact(metatype) && nargs == 1 && nkwds == 0) {
PyObject *x = PyTuple_GET_ITEM(args, 0);
Py_INCREF(Py_Type(x));
return (PyObject *) Py_Type(x);
Py_INCREF(Py_TYPE(x));
return (PyObject *) Py_TYPE(x);
}
/* SF bug 475327 -- if that didn't trigger, we need 3
@ -1668,7 +1668,7 @@ type_new(PyTypeObject *metatype, PyObject *args, PyObject *kwds)
winner = metatype;
for (i = 0; i < nbases; i++) {
tmp = PyTuple_GET_ITEM(bases, i);
tmptype = Py_Type(tmp);
tmptype = Py_TYPE(tmp);
if (PyType_IsSubtype(winner, tmptype))
continue;
if (PyType_IsSubtype(tmptype, winner)) {
@ -2055,7 +2055,7 @@ _PyType_Lookup(PyTypeObject *type, PyObject *name)
static PyObject *
type_getattro(PyTypeObject *type, PyObject *name)
{
PyTypeObject *metatype = Py_Type(type);
PyTypeObject *metatype = Py_TYPE(type);
PyObject *meta_attribute, *attribute;
descrgetfunc meta_get;
@ -2072,7 +2072,7 @@ type_getattro(PyTypeObject *type, PyObject *name)
meta_attribute = _PyType_Lookup(metatype, name);
if (meta_attribute != NULL) {
meta_get = Py_Type(meta_attribute)->tp_descr_get;
meta_get = Py_TYPE(meta_attribute)->tp_descr_get;
if (meta_get != NULL && PyDescr_IsData(meta_attribute)) {
/* Data descriptors implement tp_descr_set to intercept
@ -2090,7 +2090,7 @@ type_getattro(PyTypeObject *type, PyObject *name)
attribute = _PyType_Lookup(type, name);
if (attribute != NULL) {
/* Implement descriptor functionality, if any */
descrgetfunc local_get = Py_Type(attribute)->tp_descr_get;
descrgetfunc local_get = Py_TYPE(attribute)->tp_descr_get;
Py_XDECREF(meta_attribute);
@ -2168,7 +2168,7 @@ type_dealloc(PyTypeObject *type)
PyObject_Free((char *)type->tp_doc);
Py_XDECREF(et->ht_name);
Py_XDECREF(et->ht_slots);
Py_Type(type)->tp_free((PyObject *)type);
Py_TYPE(type)->tp_free((PyObject *)type);
}
static PyObject *
@ -2388,7 +2388,7 @@ object_init(PyObject *self, PyObject *args, PyObject *kwds)
{
int err = 0;
if (excess_args(args, kwds)) {
PyTypeObject *type = Py_Type(self);
PyTypeObject *type = Py_TYPE(self);
if (type->tp_init != object_init &&
type->tp_new != object_new)
{
@ -2435,7 +2435,7 @@ object_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
static void
object_dealloc(PyObject *self)
{
Py_Type(self)->tp_free(self);
Py_TYPE(self)->tp_free(self);
}
static PyObject *
@ -2444,7 +2444,7 @@ object_repr(PyObject *self)
PyTypeObject *type;
PyObject *mod, *name, *rtn;
type = Py_Type(self);
type = Py_TYPE(self);
mod = type_module(type, NULL);
if (mod == NULL)
PyErr_Clear();
@ -2470,7 +2470,7 @@ object_str(PyObject *self)
{
unaryfunc f;
f = Py_Type(self)->tp_repr;
f = Py_TYPE(self)->tp_repr;
if (f == NULL)
f = object_repr;
return f(self);
@ -2519,8 +2519,8 @@ object_richcompare(PyObject *self, PyObject *other, int op)
static PyObject *
object_get_class(PyObject *self, void *closure)
{
Py_INCREF(Py_Type(self));
return (PyObject *)(Py_Type(self));
Py_INCREF(Py_TYPE(self));
return (PyObject *)(Py_TYPE(self));
}
static int
@ -2605,7 +2605,7 @@ compatible_for_assignment(PyTypeObject* oldto, PyTypeObject* newto, char* attr)
static int
object_set_class(PyObject *self, PyObject *value, void *closure)
{
PyTypeObject *oldto = Py_Type(self);
PyTypeObject *oldto = Py_TYPE(self);
PyTypeObject *newto;
if (value == NULL) {
@ -2616,7 +2616,7 @@ object_set_class(PyObject *self, PyObject *value, void *closure)
if (!PyType_Check(value)) {
PyErr_Format(PyExc_TypeError,
"__class__ must be set to new-style class, not '%s' object",
Py_Type(value)->tp_name);
Py_TYPE(value)->tp_name);
return -1;
}
newto = (PyTypeObject *)value;
@ -2629,7 +2629,7 @@ object_set_class(PyObject *self, PyObject *value, void *closure)
}
if (compatible_for_assignment(newto, oldto, "__class__")) {
Py_INCREF(newto);
Py_Type(self) = newto;
Py_TYPE(self) = newto;
Py_DECREF(oldto);
return 0;
}
@ -2725,7 +2725,7 @@ reduce_2(PyObject *obj)
if (args != NULL && !PyTuple_Check(args)) {
PyErr_Format(PyExc_TypeError,
"__getnewargs__ should return a tuple, "
"not '%.200s'", Py_Type(args)->tp_name);
"not '%.200s'", Py_TYPE(args)->tp_name);
goto end;
}
}
@ -3403,8 +3403,8 @@ PyType_Ready(PyTypeObject *type)
NULL when type is &PyBaseObject_Type, and we know its ob_type is
not NULL (it's initialized to &PyType_Type). But coverity doesn't
know that. */
if (Py_Type(type) == NULL && base != NULL)
Py_Type(type) = Py_Type(base);
if (Py_TYPE(type) == NULL && base != NULL)
Py_TYPE(type) = Py_TYPE(base);
/* Initialize tp_bases */
bases = type->tp_bases;
@ -3673,7 +3673,7 @@ wrap_binaryfunc_r(PyObject *self, PyObject *args, void *wrapped)
if (!check_num_args(args, 1))
return NULL;
other = PyTuple_GET_ITEM(args, 0);
if (!PyType_IsSubtype(Py_Type(other), Py_Type(self))) {
if (!PyType_IsSubtype(Py_TYPE(other), Py_TYPE(self))) {
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
}
@ -3742,7 +3742,7 @@ getindex(PyObject *self, PyObject *arg)
if (i == -1 && PyErr_Occurred())
return -1;
if (i < 0) {
PySequenceMethods *sq = Py_Type(self)->tp_as_sequence;
PySequenceMethods *sq = Py_TYPE(self)->tp_as_sequence;
if (sq && sq->sq_length) {
Py_ssize_t n = (*sq->sq_length)(self);
if (n < 0)
@ -3874,14 +3874,14 @@ wrap_cmpfunc(PyObject *self, PyObject *args, void *wrapped)
if (!check_num_args(args, 1))
return NULL;
other = PyTuple_GET_ITEM(args, 0);
if (Py_Type(other)->tp_compare != func &&
!PyType_IsSubtype(Py_Type(other), Py_Type(self))) {
if (Py_TYPE(other)->tp_compare != func &&
!PyType_IsSubtype(Py_TYPE(other), Py_TYPE(self))) {
PyErr_Format(
PyExc_TypeError,
"%s.__cmp__(x,y) requires y to be a '%s', not a '%s'",
Py_Type(self)->tp_name,
Py_Type(self)->tp_name,
Py_Type(other)->tp_name);
Py_TYPE(self)->tp_name,
Py_TYPE(self)->tp_name,
Py_TYPE(other)->tp_name);
return NULL;
}
res = (*func)(self, other);
@ -3895,7 +3895,7 @@ wrap_cmpfunc(PyObject *self, PyObject *args, void *wrapped)
static int
hackcheck(PyObject *self, setattrofunc func, char *what)
{
PyTypeObject *type = Py_Type(self);
PyTypeObject *type = Py_TYPE(self);
while (type && type->tp_flags & Py_TPFLAGS_HEAPTYPE)
type = type->tp_base;
/* If type is NULL now, this is a really weird type.
@ -4095,7 +4095,7 @@ tp_new_wrapper(PyObject *self, PyObject *args, PyObject *kwds)
PyErr_Format(PyExc_TypeError,
"%s.__new__(X): X is not a type object (%s)",
type->tp_name,
Py_Type(arg0)->tp_name);
Py_TYPE(arg0)->tp_name);
return NULL;
}
subtype = (PyTypeObject *)arg0;
@ -4186,14 +4186,14 @@ method_is_overloaded(PyObject *left, PyObject *right, char *name)
PyObject *a, *b;
int ok;
b = PyObject_GetAttrString((PyObject *)(Py_Type(right)), name);
b = PyObject_GetAttrString((PyObject *)(Py_TYPE(right)), name);
if (b == NULL) {
PyErr_Clear();
/* If right doesn't have it, it's not overloaded */
return 0;
}
a = PyObject_GetAttrString((PyObject *)(Py_Type(left)), name);
a = PyObject_GetAttrString((PyObject *)(Py_TYPE(left)), name);
if (a == NULL) {
PyErr_Clear();
Py_DECREF(b);
@ -4218,14 +4218,14 @@ static PyObject * \
FUNCNAME(PyObject *self, PyObject *other) \
{ \
static PyObject *cache_str, *rcache_str; \
int do_other = Py_Type(self) != Py_Type(other) && \
Py_Type(other)->tp_as_number != NULL && \
Py_Type(other)->tp_as_number->SLOTNAME == TESTFUNC; \
if (Py_Type(self)->tp_as_number != NULL && \
Py_Type(self)->tp_as_number->SLOTNAME == TESTFUNC) { \
int do_other = Py_TYPE(self) != Py_TYPE(other) && \
Py_TYPE(other)->tp_as_number != NULL && \
Py_TYPE(other)->tp_as_number->SLOTNAME == TESTFUNC; \
if (Py_TYPE(self)->tp_as_number != NULL && \
Py_TYPE(self)->tp_as_number->SLOTNAME == TESTFUNC) { \
PyObject *r; \
if (do_other && \
PyType_IsSubtype(Py_Type(other), Py_Type(self)) && \
PyType_IsSubtype(Py_TYPE(other), Py_TYPE(self)) && \
method_is_overloaded(self, other, ROPSTR)) { \
r = call_maybe( \
other, ROPSTR, &rcache_str, "(O)", self); \
@ -4237,7 +4237,7 @@ FUNCNAME(PyObject *self, PyObject *other) \
r = call_maybe( \
self, OPSTR, &cache_str, "(O)", other); \
if (r != Py_NotImplemented || \
Py_Type(other) == Py_Type(self)) \
Py_TYPE(other) == Py_TYPE(self)) \
return r; \
Py_DECREF(r); \
} \
@ -4295,12 +4295,12 @@ slot_sq_item(PyObject *self, Py_ssize_t i)
if (getitem_str == NULL)
return NULL;
}
func = _PyType_Lookup(Py_Type(self), getitem_str);
func = _PyType_Lookup(Py_TYPE(self), getitem_str);
if (func != NULL) {
if ((f = Py_Type(func)->tp_descr_get) == NULL)
if ((f = Py_TYPE(func)->tp_descr_get) == NULL)
Py_INCREF(func);
else {
func = f(func, self, (PyObject *)(Py_Type(self)));
func = f(func, self, (PyObject *)(Py_TYPE(self)));
if (func == NULL) {
return NULL;
}
@ -4418,8 +4418,8 @@ slot_nb_power(PyObject *self, PyObject *other, PyObject *modulus)
/* Three-arg power doesn't use __rpow__. But ternary_op
can call this when the second argument's type uses
slot_nb_power, so check before calling self.__pow__. */
if (Py_Type(self)->tp_as_number != NULL &&
Py_Type(self)->tp_as_number->nb_power == slot_nb_power) {
if (Py_TYPE(self)->tp_as_number != NULL &&
Py_TYPE(self)->tp_as_number->nb_power == slot_nb_power) {
return call_method(self, "__pow__", &pow_str,
"(OO)", other, modulus);
}
@ -4464,7 +4464,7 @@ slot_nb_bool(PyObject *self)
PyErr_Format(PyExc_TypeError,
"__bool__ should return "
"bool, returned %s",
Py_Type(temp)->tp_name);
Py_TYPE(temp)->tp_name);
result = -1;
}
Py_DECREF(temp);
@ -4555,12 +4555,12 @@ _PyObject_SlotCompare(PyObject *self, PyObject *other)
{
int c;
if (Py_Type(self)->tp_compare == _PyObject_SlotCompare) {
if (Py_TYPE(self)->tp_compare == _PyObject_SlotCompare) {
c = half_compare(self, other);
if (c <= 1)
return c;
}
if (Py_Type(other)->tp_compare == _PyObject_SlotCompare) {
if (Py_TYPE(other)->tp_compare == _PyObject_SlotCompare) {
c = half_compare(other, self);
if (c < -1)
return -2;
@ -4585,7 +4585,7 @@ slot_tp_repr(PyObject *self)
}
PyErr_Clear();
return PyUnicode_FromFormat("<%s object at %p>",
Py_Type(self)->tp_name, self);
Py_TYPE(self)->tp_name, self);
}
static PyObject *
@ -4628,7 +4628,7 @@ slot_tp_hash(PyObject *self)
if (func == NULL) {
PyErr_Format(PyExc_TypeError, "unhashable type: '%.200s'",
Py_Type(self)->tp_name);
Py_TYPE(self)->tp_name);
return -1;
}
@ -4684,7 +4684,7 @@ slot_tp_getattro(PyObject *self, PyObject *name)
static PyObject *
slot_tp_getattr_hook(PyObject *self, PyObject *name)
{
PyTypeObject *tp = Py_Type(self);
PyTypeObject *tp = Py_TYPE(self);
PyObject *getattr, *getattribute, *res;
static PyObject *getattribute_str = NULL;
static PyObject *getattr_str = NULL;
@ -4708,7 +4708,7 @@ slot_tp_getattr_hook(PyObject *self, PyObject *name)
}
getattribute = _PyType_Lookup(tp, getattribute_str);
if (getattribute == NULL ||
(Py_Type(getattribute) == &PyWrapperDescr_Type &&
(Py_TYPE(getattribute) == &PyWrapperDescr_Type &&
((PyWrapperDescrObject *)getattribute)->d_wrapped ==
(void *)PyObject_GenericGetAttr))
res = PyObject_GenericGetAttr(self, name);
@ -4767,13 +4767,13 @@ slot_tp_richcompare(PyObject *self, PyObject *other, int op)
{
PyObject *res;
if (Py_Type(self)->tp_richcompare == slot_tp_richcompare) {
if (Py_TYPE(self)->tp_richcompare == slot_tp_richcompare) {
res = half_richcompare(self, other, op);
if (res != Py_NotImplemented)
return res;
Py_DECREF(res);
}
if (Py_Type(other)->tp_richcompare == slot_tp_richcompare) {
if (Py_TYPE(other)->tp_richcompare == slot_tp_richcompare) {
res = half_richcompare(other, self, _Py_SwappedOp[op]);
if (res != Py_NotImplemented) {
return res;
@ -4806,7 +4806,7 @@ slot_tp_iter(PyObject *self)
if (func == NULL) {
PyErr_Format(PyExc_TypeError,
"'%.200s' object is not iterable",
Py_Type(self)->tp_name);
Py_TYPE(self)->tp_name);
return NULL;
}
Py_DECREF(func);
@ -4823,7 +4823,7 @@ slot_tp_iternext(PyObject *self)
static PyObject *
slot_tp_descr_get(PyObject *self, PyObject *obj, PyObject *type)
{
PyTypeObject *tp = Py_Type(self);
PyTypeObject *tp = Py_TYPE(self);
PyObject *get;
static PyObject *get_str = NULL;
@ -4881,7 +4881,7 @@ slot_tp_init(PyObject *self, PyObject *args, PyObject *kwds)
if (res != Py_None) {
PyErr_Format(PyExc_TypeError,
"__init__() should return None, not '%.200s'",
Py_Type(res)->tp_name);
Py_TYPE(res)->tp_name);
Py_DECREF(res);
return -1;
}
@ -4966,7 +4966,7 @@ slot_tp_del(PyObject *self)
_Py_NewReference(self);
self->ob_refcnt = refcnt;
}
assert(!PyType_IS_GC(Py_Type(self)) ||
assert(!PyType_IS_GC(Py_TYPE(self)) ||
_Py_AS_GC(self)->gc.gc_refs != _PyGC_REFS_UNTRACKED);
/* If Py_REF_DEBUG, _Py_NewReference bumped _Py_RefTotal, so
* we need to undo that. */
@ -4978,8 +4978,8 @@ slot_tp_del(PyObject *self)
* undone.
*/
#ifdef COUNT_ALLOCS
--Py_Type(self)->tp_frees;
--Py_Type(self)->tp_allocs;
--Py_TYPE(self)->tp_frees;
--Py_TYPE(self)->tp_allocs;
#endif
}
@ -5314,7 +5314,7 @@ update_one_slot(PyTypeObject *type, slotdef *p)
descr = _PyType_Lookup(type, p->name_strobj);
if (descr == NULL)
continue;
if (Py_Type(descr) == &PyWrapperDescr_Type) {
if (Py_TYPE(descr) == &PyWrapperDescr_Type) {
void **tptr = resolve_slotdups(type, p->name_strobj);
if (tptr == NULL || tptr == ptr)
generic = p->function;
@ -5329,7 +5329,7 @@ update_one_slot(PyTypeObject *type, slotdef *p)
use_generic = 1;
}
}
else if (Py_Type(descr) == &PyCFunction_Type &&
else if (Py_TYPE(descr) == &PyCFunction_Type &&
PyCFunction_GET_FUNCTION(descr) ==
(PyCFunction)tp_new_wrapper &&
strcmp(p->name, "__new__") == 0)
@ -5600,7 +5600,7 @@ super_dealloc(PyObject *self)
Py_XDECREF(su->obj);
Py_XDECREF(su->type);
Py_XDECREF(su->obj_type);
Py_Type(self)->tp_free(self);
Py_TYPE(self)->tp_free(self);
}
static PyObject *
@ -5663,7 +5663,7 @@ super_getattro(PyObject *self, PyObject *name)
res = PyDict_GetItem(dict, name);
if (res != NULL) {
Py_INCREF(res);
f = Py_Type(res)->tp_descr_get;
f = Py_TYPE(res)->tp_descr_get;
if (f != NULL) {
tmp = f(res,
/* Only pass 'obj' param if
@ -5699,7 +5699,7 @@ supercheck(PyTypeObject *type, PyObject *obj)
the normal case; the return value is obj.__class__.
But... when obj is an instance, we want to allow for the case where
Py_Type(obj) is not a subclass of type, but obj.__class__ is!
Py_TYPE(obj) is not a subclass of type, but obj.__class__ is!
This will allow using super() with a proxy for obj.
*/
@ -5710,9 +5710,9 @@ supercheck(PyTypeObject *type, PyObject *obj)
}
/* Normal case */
if (PyType_IsSubtype(Py_Type(obj), type)) {
Py_INCREF(Py_Type(obj));
return Py_Type(obj);
if (PyType_IsSubtype(Py_TYPE(obj), type)) {
Py_INCREF(Py_TYPE(obj));
return Py_TYPE(obj);
}
else {
/* Try the slow way */
@ -5729,7 +5729,7 @@ supercheck(PyTypeObject *type, PyObject *obj)
if (class_attr != NULL &&
PyType_Check(class_attr) &&
(PyTypeObject *)class_attr != Py_Type(obj))
(PyTypeObject *)class_attr != Py_TYPE(obj))
{
int ok = PyType_IsSubtype(
(PyTypeObject *)class_attr, type);
@ -5760,10 +5760,10 @@ super_descr_get(PyObject *self, PyObject *obj, PyObject *type)
Py_INCREF(self);
return self;
}
if (Py_Type(su) != &PySuper_Type)
if (Py_TYPE(su) != &PySuper_Type)
/* If su is an instance of a (strict) subclass of super,
call its type */
return PyObject_CallFunctionObjArgs((PyObject *)Py_Type(su),
return PyObject_CallFunctionObjArgs((PyObject *)Py_TYPE(su),
su->type, obj, NULL);
else {
/* Inline the common case */
@ -5845,7 +5845,7 @@ super_init(PyObject *self, PyObject *args, PyObject *kwds)
if (!PyType_Check(type)) {
PyErr_Format(PyExc_SystemError,
"super(): __class__ is not a type (%s)",
Py_Type(type)->tp_name);
Py_TYPE(type)->tp_name);
return -1;
}
break;