summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorDong-hee Na <donghee.na92@gmail.com>2020-02-17 10:09:15 (GMT)
committerGitHub <noreply@github.com>2020-02-17 10:09:15 (GMT)
commit1b55b65638254aa78b005fbf0b71fb02499f1852 (patch)
tree3c9a1a7b47443d75d73a57002ecb3a49ae88ce2c /Objects
parenta7847590f07655e794d7c62130aea245a110acef (diff)
downloadcpython-1b55b65638254aa78b005fbf0b71fb02499f1852.zip
cpython-1b55b65638254aa78b005fbf0b71fb02499f1852.tar.gz
cpython-1b55b65638254aa78b005fbf0b71fb02499f1852.tar.bz2
bpo-39573: Clean up modules and headers to use Py_IS_TYPE() function (GH-18521)
Diffstat (limited to 'Objects')
-rw-r--r--Objects/classobject.c2
-rw-r--r--Objects/dictobject.c12
-rw-r--r--Objects/typeobject.c2
3 files changed, 8 insertions, 8 deletions
diff --git a/Objects/classobject.c b/Objects/classobject.c
index 33afbcd..97f50fa 100644
--- a/Objects/classobject.c
+++ b/Objects/classobject.c
@@ -37,7 +37,7 @@ static PyObject *
method_vectorcall(PyObject *method, PyObject *const *args,
size_t nargsf, PyObject *kwnames)
{
- assert(Py_TYPE(method) == &PyMethod_Type);
+ assert(Py_IS_TYPE(method, &PyMethod_Type));
PyThreadState *tstate = _PyThreadState_GET();
PyObject *self = PyMethod_GET_SELF(method);
diff --git a/Objects/dictobject.c b/Objects/dictobject.c
index 8f6ce39..86ac4ef 100644
--- a/Objects/dictobject.c
+++ b/Objects/dictobject.c
@@ -608,7 +608,7 @@ new_dict(PyDictKeysObject *keys, PyObject **values)
if (numfree) {
mp = free_list[--numfree];
assert (mp != NULL);
- assert (Py_TYPE(mp) == &PyDict_Type);
+ assert (Py_IS_TYPE(mp, &PyDict_Type));
_Py_NewReference((PyObject *)mp);
}
else {
@@ -2007,7 +2007,7 @@ dict_dealloc(PyDictObject *mp)
assert(keys->dk_refcnt == 1);
dictkeys_decref(keys);
}
- if (numfree < PyDict_MAXFREELIST && Py_TYPE(mp) == &PyDict_Type)
+ if (numfree < PyDict_MAXFREELIST && Py_IS_TYPE(mp, &PyDict_Type))
free_list[numfree++] = mp;
else
Py_TYPE(mp)->tp_free((PyObject *)mp);
@@ -3864,15 +3864,15 @@ dictreviter_iternext(dictiterobject *di)
di->di_pos = i-1;
di->len--;
- if (Py_TYPE(di) == &PyDictRevIterKey_Type) {
+ if (Py_IS_TYPE(di, &PyDictRevIterKey_Type)) {
Py_INCREF(key);
return key;
}
- else if (Py_TYPE(di) == &PyDictRevIterValue_Type) {
+ else if (Py_IS_TYPE(di, &PyDictRevIterValue_Type)) {
Py_INCREF(value);
return value;
}
- else if (Py_TYPE(di) == &PyDictRevIterItem_Type) {
+ else if (Py_IS_TYPE(di, &PyDictRevIterItem_Type)) {
Py_INCREF(key);
Py_INCREF(value);
result = di->di_result;
@@ -4236,7 +4236,7 @@ _PyDictView_Intersect(PyObject* self, PyObject *other)
/* if other is a set and self is smaller than other,
reuse set intersection logic */
- if (Py_TYPE(other) == &PySet_Type && len_self <= PyObject_Size(other)) {
+ if (Py_IS_TYPE(other, &PySet_Type) && len_self <= PyObject_Size(other)) {
_Py_IDENTIFIER(intersection);
return _PyObject_CallMethodIdObjArgs(other, &PyId_intersection, self, NULL);
}
diff --git a/Objects/typeobject.c b/Objects/typeobject.c
index f32ccb1..e51059b 100644
--- a/Objects/typeobject.c
+++ b/Objects/typeobject.c
@@ -302,7 +302,7 @@ type_mro_modified(PyTypeObject *type, PyObject *bases) {
each subclass when their mro is recursively updated.
*/
Py_ssize_t i, n;
- int custom = (Py_TYPE(type) != &PyType_Type);
+ int custom = !Py_IS_TYPE(type, &PyType_Type);
int unbound;
PyObject *mro_meth = NULL;
PyObject *type_mro_meth = NULL;