bpo-39573: Clean up modules and headers to use Py_IS_TYPE() function (GH-18521)

This commit is contained in:
Dong-hee Na 2020-02-17 19:09:15 +09:00 committed by GitHub
parent a7847590f0
commit 1b55b65638
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
33 changed files with 56 additions and 56 deletions

View file

@ -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);
}