mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
bpo-39573: Clean up modules and headers to use Py_IS_TYPE() function (GH-18521)
This commit is contained in:
parent
a7847590f0
commit
1b55b65638
33 changed files with 56 additions and 56 deletions
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue