summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorAndy Lester <andy@petdance.com>2020-03-04 13:15:20 (GMT)
committerGitHub <noreply@github.com>2020-03-04 13:15:20 (GMT)
commitdffe4c07095e0c693e094d3c140e85a68bd8128e (patch)
tree1f58f4c2f76d6f630c5279a7b72d31bb6b4d8873 /Objects
parent22a9a546ff3bf2a63d77ca1e5494e758bc59132f (diff)
downloadcpython-dffe4c07095e0c693e094d3c140e85a68bd8128e.zip
cpython-dffe4c07095e0c693e094d3c140e85a68bd8128e.tar.gz
cpython-dffe4c07095e0c693e094d3c140e85a68bd8128e.tar.bz2
bpo-39573: Finish converting to new Py_IS_TYPE() macro (GH-18601)
Diffstat (limited to 'Objects')
-rw-r--r--Objects/abstract.c2
-rw-r--r--Objects/descrobject.c4
-rw-r--r--Objects/exceptions.c4
-rw-r--r--Objects/genobject.c6
-rw-r--r--Objects/listobject.c22
-rw-r--r--Objects/namespaceobject.c2
-rw-r--r--Objects/tupleobject.c2
-rw-r--r--Objects/typeobject.c8
-rw-r--r--Objects/unicodeobject.c4
9 files changed, 27 insertions, 27 deletions
diff --git a/Objects/abstract.c b/Objects/abstract.c
index de5652f..454e0da 100644
--- a/Objects/abstract.c
+++ b/Objects/abstract.c
@@ -2472,7 +2472,7 @@ object_recursive_isinstance(PyThreadState *tstate, PyObject *inst, PyObject *cls
_Py_IDENTIFIER(__instancecheck__);
/* Quick test for an exact match */
- if (Py_TYPE(inst) == (PyTypeObject *)cls) {
+ if (Py_IS_TYPE(inst, (PyTypeObject *)cls)) {
return 1;
}
diff --git a/Objects/descrobject.c b/Objects/descrobject.c
index aaaa447..c96945b 100644
--- a/Objects/descrobject.c
+++ b/Objects/descrobject.c
@@ -1178,7 +1178,7 @@ typedef struct {
PyObject *self;
} wrapperobject;
-#define Wrapper_Check(v) (Py_TYPE(v) == &_PyMethodWrapper_Type)
+#define Wrapper_Check(v) Py_IS_TYPE(v, &_PyMethodWrapper_Type)
static void
wrapper_dealloc(wrapperobject *wp)
@@ -1628,7 +1628,7 @@ property_init_impl(propertyobject *self, PyObject *fget, PyObject *fset,
if (rc <= 0) {
return rc;
}
- if (Py_TYPE(self) == &PyProperty_Type) {
+ if (Py_IS_TYPE(self, &PyProperty_Type)) {
Py_XSETREF(self->prop_doc, get_doc);
}
else {
diff --git a/Objects/exceptions.c b/Objects/exceptions.c
index 631f537..2baec5e 100644
--- a/Objects/exceptions.c
+++ b/Objects/exceptions.c
@@ -875,7 +875,7 @@ oserror_init(PyOSErrorObject *self, PyObject **p_args,
/* self->filename will remain Py_None otherwise */
if (filename && filename != Py_None) {
- if (Py_TYPE(self) == (PyTypeObject *) PyExc_BlockingIOError &&
+ if (Py_IS_TYPE(self, (PyTypeObject *) PyExc_BlockingIOError) &&
PyNumber_Check(filename)) {
/* BlockingIOError's 3rd argument can be the number of
* characters written.
@@ -1379,7 +1379,7 @@ SyntaxError_init(PySyntaxErrorObject *self, PyObject *args, PyObject *kwds)
* Only applies to SyntaxError instances, not to subclasses such
* as TabError or IndentationError (see issue #31161)
*/
- if ((PyObject*)Py_TYPE(self) == PyExc_SyntaxError &&
+ if (Py_IS_TYPE(self, (PyTypeObject *)PyExc_SyntaxError) &&
self->text && PyUnicode_Check(self->text) &&
_report_missing_parentheses(self) < 0) {
return -1;
diff --git a/Objects/genobject.c b/Objects/genobject.c
index ef892bb..6bb08ae 100644
--- a/Objects/genobject.c
+++ b/Objects/genobject.c
@@ -1216,10 +1216,10 @@ static PyAsyncGenASend *ag_asend_freelist[_PyAsyncGen_MAXFREELIST];
static int ag_asend_freelist_free = 0;
#define _PyAsyncGenWrappedValue_CheckExact(o) \
- (Py_TYPE(o) == &_PyAsyncGenWrappedValue_Type)
+ Py_IS_TYPE(o, &_PyAsyncGenWrappedValue_Type)
#define PyAsyncGenASend_CheckExact(o) \
- (Py_TYPE(o) == &_PyAsyncGenASend_Type)
+ Py_IS_TYPE(o, &_PyAsyncGenASend_Type)
static int
@@ -1442,7 +1442,7 @@ PyAsyncGen_ClearFreeLists(void)
while (ag_asend_freelist_free) {
PyAsyncGenASend *o;
o = ag_asend_freelist[--ag_asend_freelist_free];
- assert(Py_TYPE(o) == &_PyAsyncGenASend_Type);
+ assert(Py_IS_TYPE(o, &_PyAsyncGenASend_Type));
PyObject_GC_Del(o);
}
diff --git a/Objects/listobject.c b/Objects/listobject.c
index 3ac03b7..46bc777 100644
--- a/Objects/listobject.c
+++ b/Objects/listobject.c
@@ -2052,8 +2052,8 @@ unsafe_latin_compare(PyObject *v, PyObject *w, MergeState *ms)
int res;
/* Modified from Objects/unicodeobject.c:unicode_compare, assuming: */
- assert(Py_TYPE(v) == Py_TYPE(w));
- assert(Py_TYPE(v) == &PyUnicode_Type);
+ assert(Py_IS_TYPE(v, &PyUnicode_Type));
+ assert(Py_IS_TYPE(w, &PyUnicode_Type));
assert(PyUnicode_KIND(v) == PyUnicode_KIND(w));
assert(PyUnicode_KIND(v) == PyUnicode_1BYTE_KIND);
@@ -2075,8 +2075,8 @@ unsafe_long_compare(PyObject *v, PyObject *w, MergeState *ms)
PyLongObject *vl, *wl; sdigit v0, w0; int res;
/* Modified from Objects/longobject.c:long_compare, assuming: */
- assert(Py_TYPE(v) == Py_TYPE(w));
- assert(Py_TYPE(v) == &PyLong_Type);
+ assert(Py_IS_TYPE(v, &PyLong_Type));
+ assert(Py_IS_TYPE(w, &PyLong_Type));
assert(Py_ABS(Py_SIZE(v)) <= 1);
assert(Py_ABS(Py_SIZE(w)) <= 1);
@@ -2103,8 +2103,8 @@ unsafe_float_compare(PyObject *v, PyObject *w, MergeState *ms)
int res;
/* Modified from Objects/floatobject.c:float_richcompare, assuming: */
- assert(Py_TYPE(v) == Py_TYPE(w));
- assert(Py_TYPE(v) == &PyFloat_Type);
+ assert(Py_IS_TYPE(v, &PyFloat_Type));
+ assert(Py_IS_TYPE(w, &PyFloat_Type));
res = PyFloat_AS_DOUBLE(v) < PyFloat_AS_DOUBLE(w);
assert(res == PyObject_RichCompareBool(v, w, Py_LT));
@@ -2125,8 +2125,8 @@ unsafe_tuple_compare(PyObject *v, PyObject *w, MergeState *ms)
int k;
/* Modified from Objects/tupleobject.c:tuplerichcompare, assuming: */
- assert(Py_TYPE(v) == Py_TYPE(w));
- assert(Py_TYPE(v) == &PyTuple_Type);
+ assert(Py_IS_TYPE(v, &PyTuple_Type));
+ assert(Py_IS_TYPE(w, &PyTuple_Type));
assert(Py_SIZE(v) > 0);
assert(Py_SIZE(w) > 0);
@@ -2247,7 +2247,7 @@ list_sort_impl(PyListObject *self, PyObject *keyfunc, int reverse)
* set ms appropriately. */
if (saved_ob_size > 1) {
/* Assume the first element is representative of the whole list. */
- int keys_are_in_tuples = (Py_TYPE(lo.keys[0]) == &PyTuple_Type &&
+ int keys_are_in_tuples = (Py_IS_TYPE(lo.keys[0], &PyTuple_Type) &&
Py_SIZE(lo.keys[0]) > 0);
PyTypeObject* key_type = (keys_are_in_tuples ?
@@ -2262,7 +2262,7 @@ list_sort_impl(PyListObject *self, PyObject *keyfunc, int reverse)
for (i=0; i < saved_ob_size; i++) {
if (keys_are_in_tuples &&
- !(Py_TYPE(lo.keys[i]) == &PyTuple_Type && Py_SIZE(lo.keys[i]) != 0)) {
+ !(Py_IS_TYPE(lo.keys[i], &PyTuple_Type) && Py_SIZE(lo.keys[i]) != 0)) {
keys_are_in_tuples = 0;
keys_are_all_same_type = 0;
break;
@@ -2275,7 +2275,7 @@ list_sort_impl(PyListObject *self, PyObject *keyfunc, int reverse)
PyTuple_GET_ITEM(lo.keys[i], 0) :
lo.keys[i]);
- if (Py_TYPE(key) != key_type) {
+ if (!Py_IS_TYPE(key, key_type)) {
keys_are_all_same_type = 0;
/* If keys are in tuple we must loop over the whole list to make
sure all items are tuples */
diff --git a/Objects/namespaceobject.c b/Objects/namespaceobject.c
index 5c7163f..a28b9e5 100644
--- a/Objects/namespaceobject.c
+++ b/Objects/namespaceobject.c
@@ -72,7 +72,7 @@ namespace_repr(PyObject *ns)
PyObject *separator, *pairsrepr, *repr = NULL;
const char * name;
- name = (Py_TYPE(ns) == &_PyNamespace_Type) ? "namespace"
+ name = Py_IS_TYPE(ns, &_PyNamespace_Type) ? "namespace"
: Py_TYPE(ns)->tp_name;
i = Py_ReprEnter(ns);
diff --git a/Objects/tupleobject.c b/Objects/tupleobject.c
index d114bd6..92374cc 100644
--- a/Objects/tupleobject.c
+++ b/Objects/tupleobject.c
@@ -237,7 +237,7 @@ tupledealloc(PyTupleObject *op)
#if PyTuple_MAXSAVESIZE > 0
if (len < PyTuple_MAXSAVESIZE &&
numfree[len] < PyTuple_MAXFREELIST &&
- Py_TYPE(op) == &PyTuple_Type)
+ Py_IS_TYPE(op, &PyTuple_Type))
{
op->ob_item[0] = (PyObject *) free_list[len];
numfree[len]++;
diff --git a/Objects/typeobject.c b/Objects/typeobject.c
index e51059b..cf749ef 100644
--- a/Objects/typeobject.c
+++ b/Objects/typeobject.c
@@ -5335,7 +5335,7 @@ 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) {
+ if (Py_IS_TYPE(type, NULL) && base != NULL) {
Py_SET_TYPE(type, Py_TYPE(base));
}
@@ -6645,7 +6645,7 @@ slot_tp_getattr_hook(PyObject *self, PyObject *name)
needed, with call_attribute. */
getattribute = _PyType_LookupId(tp, &PyId___getattribute__);
if (getattribute == NULL ||
- (Py_TYPE(getattribute) == &PyWrapperDescr_Type &&
+ (Py_IS_TYPE(getattribute, &PyWrapperDescr_Type) &&
((PyWrapperDescrObject *)getattribute)->d_wrapped ==
(void *)PyObject_GenericGetAttr))
res = PyObject_GenericGetAttr(self, name);
@@ -7352,7 +7352,7 @@ update_one_slot(PyTypeObject *type, slotdef *p)
}
continue;
}
- if (Py_TYPE(descr) == &PyWrapperDescr_Type &&
+ if (Py_IS_TYPE(descr, &PyWrapperDescr_Type) &&
((PyWrapperDescrObject *)descr)->d_base->name_strobj == p->name_strobj) {
void **tptr = resolve_slotdups(type, p->name_strobj);
if (tptr == NULL || tptr == ptr)
@@ -7375,7 +7375,7 @@ update_one_slot(PyTypeObject *type, slotdef *p)
use_generic = 1;
}
}
- else if (Py_TYPE(descr) == &PyCFunction_Type &&
+ else if (Py_IS_TYPE(descr, &PyCFunction_Type) &&
PyCFunction_GET_FUNCTION(descr) ==
(PyCFunction)(void(*)(void))tp_new_wrapper &&
ptr == (void**)&type->tp_new)
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
index e0a666f..3d99f11 100644
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -8484,7 +8484,7 @@ charmapencode_output(Py_UCS4 c, PyObject *mapping,
char *outstart;
Py_ssize_t outsize = PyBytes_GET_SIZE(*outobj);
- if (Py_TYPE(mapping) == &EncodingMapType) {
+ if (Py_IS_TYPE(mapping, &EncodingMapType)) {
int res = encoding_map_lookup(c, mapping);
Py_ssize_t requiredsize = *outpos+1;
if (res == -1)
@@ -8563,7 +8563,7 @@ charmap_encoding_error(
/* find all unencodable characters */
while (collendpos < size) {
PyObject *rep;
- if (Py_TYPE(mapping) == &EncodingMapType) {
+ if (Py_IS_TYPE(mapping, &EncodingMapType)) {
ch = PyUnicode_READ_CHAR(unicode, collendpos);
val = encoding_map_lookup(ch, mapping);
if (val != -1)